-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
37 lines (29 loc) · 926 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
FROM python:3.12-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libffi-dev \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Upgrade pip, setuptools, and wheel
RUN pip install --upgrade pip setuptools wheel
# Set working directory and copy necessary files
WORKDIR /app
COPY app.py config requirements.txt templates ./
# Create and activate a virtual environment
ENV VIRTUAL_ENV=/home/app/venv
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Install Python dependencies
RUN pip install -r requirements.txt
# Add a non-root user with UID 1000
RUN useradd --uid 1000 myuser
RUN mkdir -p /home/myuser
RUN chown -R myuser:myuser /home/myuser
USER myuser
# Expose the port and set environment variables
EXPOSE 8000
ENV FLASK_APP=app.py
# Set the default entry point
ENTRYPOINT ["gunicorn"]
CMD ["-c", "config.gunicorn", "app:create_app()"]