Skip to content

Commit

Permalink
build: docker
Browse files Browse the repository at this point in the history
  • Loading branch information
subotic committed Feb 20, 2025
1 parent 1636c32 commit 4fca342
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/venv
/dist
/target
.venv
35 changes: 22 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,40 @@ RUN ls -la dist

# ---- Setup Python Service ----
FROM python:3.11-slim AS runtime
COPY --from=ghcr.io/astral-sh/uv:0.6.2 /uv /uvx /bin/

WORKDIR /app/ark_resolver
WORKDIR /app

# Install required dependencies
RUN apt-get update && apt-get install -y libssl-dev && rm -rf /var/lib/apt/lists/*

# Create a virtual environment
RUN python -m venv /venv
ENV PATH="/venv/bin:$PATH"
# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1

# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy

# Install the project's dependencies using the lockfile and settings
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project --no-dev

# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -r requirements.txt
# Then, add the rest of the project source code and install it
# Installing separately from its dependencies allows optimal layer caching
ADD . /app

# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"

# Copy the Rust-built Python package and install it
COPY --from=builder /app/dist/*.whl .
RUN pip install *.whl && rm -f *.whl
RUN uv pip install *.whl && rm -f *.whl

# Verify the installation of the ark_resolver module
RUN python -c "import _rust; print('_rust module installed successfully')"

# Copy Python service code
COPY python/src/ark_resolver /app/ark_resolver

ENV PYTHONPATH="/app"
ENV PYTHONPATH=/app/python/src

ENTRYPOINT ["python3", "/app/ark_resolver/ark.py"]
ENTRYPOINT ["python3", "/app/python/src/ark_resolver/ark.py"]
CMD ["-s"]
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ services:
ARK_NAAN: "99999"
ARK_HTTPS_PROXY: false
ARK_REGISTRY: "app/python/src/ark_resolver/ark-registry.ini"
PYTHONPATH: "/app/python/src"

0 comments on commit 4fca342

Please sign in to comment.