Skip to content

Commit

Permalink
server: fix Docker image for uv usage
Browse files Browse the repository at this point in the history
  • Loading branch information
frankie567 committed Oct 29, 2024
1 parent 7af8817 commit c14dc29
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
14 changes: 14 additions & 0 deletions server/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.mypy_cache/
.pytest_cache/
.ruff_cache/
.venv/
.vscode/

.minio/
polar_backoffice/
tests/

ip-geolocation.mmdb
.env*
.jkws.json
.DS_Store
20 changes: 9 additions & 11 deletions server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,20 @@ FROM --platform=$BUILDPLATFORM python:3.12-slim
LABEL org.opencontainers.image.source=https://github.com/polarsource/polar
LABEL org.opencontainers.image.description="Polar"
LABEL org.opencontainers.image.licenses=Apache-2.0
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

ENV PYTHONUNBUFFERED=1
ENV UV_COMPILE_BYTECODE=1

WORKDIR /app/server

ADD uv.lock .
ADD pyproject.toml .

RUN apt-get update && apt-get install -y build-essential redis libpq-dev curl \
&& pip install --upgrade pip uv \
RUN --mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
apt-get update && apt-get install -y build-essential redis libpq-dev curl \
&& uv sync --no-group dev --no-group backoffice --frozen \
&& apt-get autoremove -y build-essential

ADD polar polar
ADD scripts scripts
ADD run_worker.py .

ADD migrations migrations
ADD alembic.ini .
ADD . /app/server/

RUN --mount=type=secret,id=IPINFO_ACCESS_TOKEN mkdir /data && curl -fsSL https://ipinfo.io/data/free/country_asn.mmdb?token=$(cat /run/secrets/IPINFO_ACCESS_TOKEN) -o /data/country_asn.mmdb
ENV POLAR_IP_GEOLOCATION_DATABASE_DIRECTORY_PATH=/data
Expand All @@ -29,4 +24,7 @@ ENV POLAR_IP_GEOLOCATION_DATABASE_NAME=country_asn.mmdb
ARG RELEASE_VERSION
ENV RELEASE_VERSION=${RELEASE_VERSION}

RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen

CMD ["uv", "run", "uvicorn", "polar.app:app", "--host", "0.0.0.0", "--port", "10000"]
3 changes: 0 additions & 3 deletions server/poetry.toml

This file was deleted.

0 comments on commit c14dc29

Please sign in to comment.