-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathDockerfile.web
More file actions
64 lines (47 loc) · 1.46 KB
/
Dockerfile.web
File metadata and controls
64 lines (47 loc) · 1.46 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# 1 - Download & Install Python 3
FROM python:3.13.2-slim-bullseye
# setup linux os packages
# 2 - Create Virtual Environment
# 3 - Install Python Packages - `pip install <package-name>`
# 4 - FastAPI Hello World
# Create a virtual environment
RUN python -m venv /opt/venv
# Set the virtual environment as the current location
ENV PATH=/opt/venv/bin:$PATH
# Upgrade pip
RUN pip install --upgrade pip
# Set Python-related environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Install os dependencies for our mini vm
RUN apt-get update && apt-get install -y \
# for postgres
libpq-dev \
# for Pillow
libjpeg-dev \
# for CairoSVG
libcairo2 \
# other
gcc \
&& rm -rf /var/lib/apt/lists/*
# Create the mini vm's code directory
RUN mkdir -p /code
# Set the working directory to that same code directory
WORKDIR /code
# Copy the requirements file into the container
COPY requirements.txt /tmp/requirements.txt
# copy the project code into the container's working directory
COPY ./src /code
# Install the Python project requirements
RUN pip install -r /tmp/requirements.txt
# make the bash script executable
COPY ./boot/docker-run.sh /opt/run.sh
RUN chmod +x /opt/run.sh
# Clean up apt cache to reduce image size
RUN apt-get remove --purge -y \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Run the FastAPI project via the runtime script
# when the container starts
CMD ["/opt/run.sh"]