Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ ENV PYTHONDONTWRITEBYTECODE=1 \

WORKDIR /app

# Copy uv from official image for better security and updates
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

COPY pyproject.toml uv.lock* ./
COPY pyproject.toml uv.lock ./

RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-install-project
uv sync --locked --no-dev --no-install-project

COPY . .

RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked
uv sync --locked --no-dev

# --- Runtime stage ---
FROM python:${PYTHON_VERSION}-slim
Expand All @@ -37,23 +36,20 @@ ENV PYTHONDONTWRITEBYTECODE=1 \

WORKDIR /app

RUN groupadd -r appuser && \
useradd -r -g appuser -u 1000 -s /sbin/nologin appuser
RUN groupadd --system flowdacity && \
useradd --system --gid flowdacity --uid 1000 --create-home --shell /usr/sbin/nologin flowdacity

COPY --from=builder --chown=appuser:appuser /app/.venv /app/.venv
COPY --from=builder --chown=flowdacity:flowdacity /app/.venv /app/.venv
COPY --from=builder --chown=flowdacity:flowdacity /app /app

COPY --chown=appuser:appuser . .
RUN chmod -R a-w /app && \
chmod -R u+rwX /app

RUN chmod -R 555 /app/fq_server && \
chmod 555 /app/*.py && \
chmod 444 /app/default.conf /app/pyproject.toml

USER appuser
USER flowdacity

EXPOSE ${PORT}

HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import httpx; httpx.get('http://127.0.0.1:${PORT}/metrics/')" || exit 1
CMD python -c "import os, httpx; port = os.environ.get('PORT', '8080'); r = httpx.get(f'http://127.0.0.1:{port}/metrics/'); raise SystemExit(0 if r.status_code < 400 else 1)"

ENTRYPOINT ["sh", "-c"]
CMD ["exec uvicorn asgi:app --host 0.0.0.0 --port ${PORT}"]
CMD ["sh", "-c", "exec uvicorn asgi:app --host 0.0.0.0 --port ${PORT}"]
Loading