-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
38 lines (28 loc) · 957 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
33
34
35
36
37
38
FROM python:3.11-slim
LABEL maintainer="Nilton Pimentel <[email protected]>"
# Environment variables to prevent Python from writing pyc files to disc
# and to ensure unbuffered mode for better logging
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Set working directory
WORKDIR /app
# Create a new user 'appuser' without a home directory and switch to it
RUN useradd appuser && chown -R appuser /app
USER appuser
# Copy source code to container
COPY . .
# Switch back to root to install system and Python dependencies
USER root
# Install system dependencies and clean up
RUN apt update -y && \
apt upgrade -y && \
apt autoremove -y && \
apt clean && \
rm -rf /var/lib/apt/lists/*
# Install Python dependencies
RUN pip install wheel && \
pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Switch back to appuser
USER appuser
EXPOSE 8000