FROM python:3.12-slim-bookworm@sha256:a116514e19457bcb7af7efe9c3dd0b9b71e85b317694e7882a1c52aa15a78134 AS runtime-base ARG VCS_REF=development ARG BUILD_DATE=unknown LABEL org.opencontainers.image.title="Fleet Ops API" \ org.opencontainers.image.revision="$VCS_REF" \ org.opencontainers.image.created="$BUILD_DATE" \ org.opencontainers.image.source="https://fleetops.itworx.tech" ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 WORKDIR /app COPY backend/requirements-prod.lock ./ RUN pip install --no-cache-dir -r requirements-prod.lock COPY backend/pyproject.toml ./ COPY backend/app ./app COPY backend/alembic ./alembic COPY backend/alembic.ini ./ COPY seed ./seed COPY knowledge ./knowledge COPY backend/entrypoint.sh ./entrypoint.sh RUN pip install --no-cache-dir --no-deps -e . && chmod +x ./entrypoint.sh \ && addgroup --system app && adduser --system --ingroup app --home /app app \ && chown -R app:app /app FROM runtime-base AS test COPY backend/requirements.lock ./requirements.lock RUN pip install --no-cache-dir -r requirements.lock COPY backend/tests ./tests COPY contracts ./contracts COPY scripts/check-contracts.py ./scripts/check-contracts.py COPY n8n/workflows ./n8n/workflows USER app FROM runtime-base AS runtime # Run migrations and the API as an unprivileged user; nothing here needs root. USER app EXPOSE 8000 CMD ["./entrypoint.sh"]