-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (47 loc) · 1.48 KB
/
Dockerfile
File metadata and controls
64 lines (47 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Multi-stage build for smaller final image
FROM python:3.12-slim as builder
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
POETRY_VERSION=1.7.0 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_CREATE=false
# Install Poetry
RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
curl -sSL https://install.python-poetry.org | python3 - && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV PATH="$POETRY_HOME/bin:$PATH"
# Set working directory
WORKDIR /app
# Copy dependency files
COPY pyproject.toml poetry.lock* ./
# Install dependencies
RUN poetry install --no-interaction --no-ansi --no-root --only main
# Copy source code
COPY src/ ./src/
# Install the application
RUN poetry install --no-interaction --no-ansi
# Final stage
FROM python:3.12-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Create non-root user
RUN useradd -m -u 1000 kickstart && \
mkdir -p /app && \
chown -R kickstart:kickstart /app
# Set working directory
WORKDIR /app
# Copy installed packages from builder
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin/kickstart /usr/local/bin/kickstart
# Copy source code (for templates)
COPY --chown=kickstart:kickstart src/ ./src/
# Switch to non-root user
USER kickstart
# Set entrypoint
ENTRYPOINT ["kickstart"]
# Default command shows help
CMD ["--help"]