Skip to content

Commit

Permalink
Use Chainguard Python image.
Browse files Browse the repository at this point in the history
Install uv from the official URL.
Explicitly specify Gunicorn filepath.
  • Loading branch information
perfectly-preserved-pie committed Sep 3, 2024
1 parent ae726ed commit b903a80
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
FROM python:3.11-slim
FROM cgr.dev/chainguard/python:latest-dev

COPY requirements.txt .

# Switch to root user to install packages
USER root

# Install curl
RUN apt-get update && apt-get install -y curl
RUN apk update && apk add --no-cache curl

# Using uv to install packages because it's fast as fuck boiiii
# https://www.youtube.com/watch?v=6E7ZGCfruaw
# https://ryxcommar.com/2024/02/15/how-to-cut-your-python-docker-builds-in-half-with-uv/
ADD --chmod=655 https://astral.sh/uv/install.sh /install.sh
RUN /install.sh && rm /install.sh
RUN /root/.cargo/bin/uv pip install --system --no-cache -r requirements.txt
# https://docs.astral.sh/uv/guides/integration/docker/
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
RUN uv pip install --system -r requirements.txt

COPY . ./

Expand All @@ -19,4 +21,4 @@ COPY . ./
# Set the number of workers to 10.
# Preload the app to avoid the overhead of loading the app for each worker. See https://www.joelsleppy.com/blog/gunicorn-application-preloading/
# Set the app to be the server variable in app.py.
CMD ["gunicorn", "-b", "0.0.0.0:80", "-k", "gevent", "--workers=10", "--preload", "app:server"]
CMD ["/usr/bin/gunicorn", "-b", "0.0.0.0:80", "-k", "gevent", "--workers=10", "--preload", "app:server"]

0 comments on commit b903a80

Please sign in to comment.