generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dockerfile
32 lines (23 loc) · 834 Bytes
/
Dockerfile
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
FROM python:3.12-slim-bullseye as builder
# Set the working directory in the container
WORKDIR /app
# Copy only necessary files
COPY pyproject.toml poetry.lock ./
COPY src ./src
COPY data ./data
COPY config ./config
# Install Poetry and dependencies in one layer
RUN pip install --no-cache-dir poetry \
&& poetry config virtualenvs.create false \
&& poetry install --no-dev --no-interaction --no-ansi \
&& pip uninstall -y poetry
# Start a new stage for a smaller final image
FROM python:3.12-slim-bullseye
WORKDIR /app
COPY --from=builder /usr/local /usr/local
COPY --from=builder /app /app
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser
EXPOSE 8000
# Run the command to start Uvicorn
CMD ["fastapi", "run", "src/main.py", "--host", "0.0.0.0", "--port", "8000"]