-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
34 lines (23 loc) · 838 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
FROM python:3.10-slim
# Update and install necessary packages
RUN apt-get update -y && apt-get upgrade -y && apt-get install -y bash build-essential git
# Create a non-root user and switch to that user
RUN useradd -m run
USER run
# Set the working directory
WORKDIR /home/run
ENV PATH="/home/run/.local/bin:${PATH}"
# Copy the requirements and install them
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy the rest of the application code
COPY --chown=run:run . .
# Run setup.py if necessary
RUN python3 setup.py
RUN rm config.py
# Copy the configuration file
RUN cp config.py.default config.py
# Set default environment variable for the port
ENV PORT=8000
# We need this to override with environment variables
CMD ["bash", "-c", "uvicorn api.main:app --host 0.0.0.0 --port ${PORT}"]