-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
37 lines (27 loc) · 1.04 KB
/
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
# Use the official Python alpine image
FROM python:alpine
# Set environment variables for production
ENV PYTHONDONTWRITEBYTECODE=1
# Prevents Python from writing .pyc files to disk
ENV PYTHONUNBUFFERED=1
# Ensures that output from Python is immediately flushed
# Set the working directory in the container
WORKDIR /app
# Create a virtual environment
RUN python -m venv /opt/venv
# Activate the virtual environment
ENV PATH="/opt/venv/bin:$PATH"
# Copy the requirements.txt file to the container
COPY requirements.txt /app/
# Install Python dependencies from requirements.txt
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
# Install gunicorn separately since it's not in requirements.txt
RUN pip install --no-cache-dir gunicorn
# Copy the rest of the application code to the container
COPY . /app/
# Expose the port Flask will run on
EXPOSE 5000
# Expose the port HealthCheck will run on
EXPOSE 9000
# Define the command to run the application using gunicorn
CMD ["gunicorn", "-b", "0.0.0.0:5000", "main:app", "--workers=4"]