Skip to content

Commit c1a16e5

Browse files
authored
deploy: use uv in docker image (#998)
1 parent 36dcc22 commit c1a16e5

4 files changed

Lines changed: 26 additions & 281 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
CLEVER_APP_ID: ${{ secrets.BE_CLEVER_APP_ID_PROD }}
4747
APP_NAME: cc_api_prod
4848
run: |
49-
uv pip compile carbonserver/pyproject.toml > requirements/requirements-api.txt
49+
uv pip compile pyproject.toml --extra api --output-file requirements/requirements-api.txt
5050
./clever-tools-latest_linux/clever link $CLEVER_APP_ID
5151
./clever-tools-latest_linux/clever deploy -f
5252

carbonserver/docker/Dockerfile

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,48 @@
11
# Dockerfile
22

3-
# Use Ubuntu to install 3 versions of Python for testing
4-
# For production, you could use python:3.8-slim
3+
# Use Ubuntu to install Python and uv
4+
# For production, you could use python:3.11-slim
55

66
FROM ubuntu:22.04@sha256:3c61d3759c2639d4b836d32a2d3c83fa0214e36f195a3421018dbaaf79cbe37f
77

88
# set work directory
9-
WORKDIR /carbonserver
9+
WORKDIR /app
1010
# set env variables
1111
ENV PYTHONDONTWRITEBYTECODE 1
1212
ENV PYTHONUNBUFFERED 1
1313
# Prevent apt to ask for region
1414
ENV DEBIAN_FRONTEND noninteractive
1515

1616
RUN apt-get update && apt-get upgrade -y && \
17-
apt-get install -y software-properties-common && \
17+
apt-get install -y software-properties-common curl && \
1818
add-apt-repository ppa:deadsnakes/ppa -y && \
1919
apt-get update && \
20-
apt-get install -y gcc libpq-dev python3.11 python3-pip
20+
apt-get install -y gcc libpq-dev python3.11 python3.11-dev
2121

22-
# Copy the requirements file from the project root
23-
# COPY ./requirements/requirements-dev.txt /carbonserver/requirements-dev.txt
24-
# RUN pip install -r /carbonserver/requirements-dev.txt
22+
RUN ln -sf /usr/bin/python3.11 /usr/bin/python && \
23+
ln -sf /usr/bin/python3.11 /usr/bin/python3
2524

26-
RUN ln -sf /usr/bin/pip3 /usr/bin/pip && \
27-
ln -sf /usr/bin/python3.11 /usr/bin/python && \
28-
ln -sf /usr/bin/python3.11 /usr/bin/python3
25+
# Download the latest UV installer
26+
ADD https://astral.sh/uv/install.sh /uv-installer.sh
2927

30-
COPY ./requirements/requirements-api.txt /carbonserver/requirements-api.txt
31-
RUN pip install -r /carbonserver/requirements-api.txt --require-hashes
28+
# Run the installer then remove it
29+
RUN sh /uv-installer.sh && rm /uv-installer.sh
30+
31+
# Ensure the installed binary is on the `PATH`
32+
ENV PATH="/root/.local/bin/:$PATH"
33+
34+
# Copy project files
35+
COPY pyproject.toml /app/
36+
COPY codecarbon /app/codecarbon
37+
COPY carbonserver /app/carbonserver
38+
39+
# Install dependencies using uv with the api dependency group
40+
RUN uv pip install --system -e ".[api]"
3241

3342
COPY ./carbonserver/docker/entrypoint.sh /opt
3443
RUN chmod a+x /opt/entrypoint.sh
3544

36-
# Copy everything from carbonserver directory to the container
37-
COPY carbonserver /carbonserver
45+
WORKDIR /app/carbonserver
3846

3947
EXPOSE 8000
4048
ENTRYPOINT ["/opt/entrypoint.sh"]

requirements/requirements-api.txt

Lines changed: 0 additions & 263 deletions
This file was deleted.

webapp/src/components/projectTokens/projectTokenTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ export const ProjectTokensTable = ({ projectId }: { projectId: string }) => {
127127
</div>
128128
<p className="text-l mt-4 p-2">
129129
Make sure to copy the token above as it will not be
130-
shown again. We&apos;ll don&apos;t store it for
131-
security reasons.
130+
shown again. We don&apos;t store it for security
131+
reasons.
132132
</p>
133133
<Button onClick={resetTokenCreation} className="mt-4">
134134
Done

0 commit comments

Comments
 (0)