-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdockerfile
32 lines (23 loc) · 850 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.10-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Set working directory in the container
WORKDIR /src
# Install system dependencies for MySQL client and MySQL server
RUN apt-get update && apt-get install -y --no-install-recommends \
default-libmysqlclient-dev build-essential && \
rm -rf /var/lib/apt/lists/*
# Copy only requirements to leverage Docker cache
COPY requirements.txt /src/
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy the application code to the container (only the src folder)
COPY src/ /src/
# Expose the port the app runs on (optional)
EXPOSE 8000
# Define a volume for persistent data
VOLUME /src/data
# Start MySQL service and run the application
CMD ["python", "./main.py"]