mirror of
https://github.com/cyclotruc/gitingest.git
synced 2026-04-28 08:39:29 +00:00
ci: add docker build & push to GHCR (#397)
This commit is contained in:
parent
f5b20dec44
commit
37eb4be3b1
2 changed files with 94 additions and 34 deletions
49
Dockerfile
49
Dockerfile
|
|
@ -1,42 +1,45 @@
|
|||
# Stage 1: Install Python dependencies
|
||||
FROM python:3.13-slim AS python-builder
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
# System build tools
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends gcc python3-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
RUN set -eux; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends gcc python3-dev; \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Metadata and code that setuptools needs
|
||||
COPY pyproject.toml .
|
||||
COPY src/ ./src/
|
||||
|
||||
# Install runtime dependencies defined in pyproject.toml
|
||||
RUN pip install --no-cache-dir --upgrade pip \
|
||||
&& pip install --no-cache-dir --timeout 1000 .
|
||||
|
||||
RUN set -eux; \
|
||||
pip install --no-cache-dir --upgrade pip; \
|
||||
pip install --no-cache-dir --timeout 1000 .
|
||||
|
||||
# Stage 2: Runtime image
|
||||
FROM python:3.13-slim
|
||||
LABEL org.opencontainers.image.source="https://github.com/coderamp-labs/gitingest"
|
||||
|
||||
# Minimal runtime utilities
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends git curl \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
ARG UID=1000
|
||||
ARG GID=1000
|
||||
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
RUN set -eux; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends git curl; \
|
||||
apt-get clean; \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1
|
||||
WORKDIR /app
|
||||
RUN useradd -m -u 1000 appuser
|
||||
RUN set -eux; \
|
||||
groupadd -g "$GID" appuser; \
|
||||
useradd -m -u "$UID" -g "$GID" appuser
|
||||
|
||||
# Copy Python site-packages and code
|
||||
COPY --from=python-builder /usr/local/lib/python3.13/site-packages/ \
|
||||
/usr/local/lib/python3.13/site-packages/
|
||||
COPY src/ ./
|
||||
COPY --from=python-builder --chown=$UID:$GID /usr/local/lib/python3.13/site-packages/ /usr/local/lib/python3.13/site-packages/
|
||||
COPY --chown=$UID:$GID src/ ./
|
||||
|
||||
# Set permissions
|
||||
RUN chown -R appuser:appuser /app
|
||||
RUN set -eux; \
|
||||
chown -R appuser:appuser /app
|
||||
USER appuser
|
||||
|
||||
EXPOSE 8000
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue