-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
32 lines (23 loc) · 959 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
# Use the official Python base image
FROM python:3.9-slim
# Set the working directory inside the container
WORKDIR /app
# set environment variables
## Prevents Python from writing pyc files to disc (equivalent to python -B)
ENV PYTHONDONTWRITEBYTECODE 1
## PYTHONUNBUFFERED: Prevents Python from buffering stdout and stderr (equivalent to python -u)
ENV PYTHONUNBUFFERED 1
# Copy the requirements file to the working directory
COPY requirements.txt .
# Install the Python dependencies
RUN pip install -r requirements.txt
# Copy the application code to the working directory
COPY . .
# create a non-root user and switch to it, for security.
RUN addgroup --system --gid 1001 "fastapi-jwt"
RUN adduser --system --uid 1001 "fastapi-jwt"
USER "fastapi-jwt"
# Expose the port on which the application will run
EXPOSE 8081
# Run the FastAPI application using uvicorn server
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8081", "--reload"]