File size: 1,044 Bytes
059d3f3
 
 
 
 
 
 
 
9758d80
059d3f3
01bbe3d
 
9758d80
059d3f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Dockerfile

# Use the official slim Python 3.9 image as a base.
# The 'slim' version is smaller, reducing our final image size.
FROM python:3.9-slim

# Set the working directory inside the container.
WORKDIR /code
RUN useradd --no-create-home --shell /bin/bash appuser

ENV HF_HOME=/code/.cache

RUN mkdir -p /code/.cache && chown -R appuser:appuser /code/.cache
# IMPORTANT OPTIMIZATION:
# First, copy and install only the dependency list.
# This prevents reinstalling hundreds of MBs of libraries every time we change
# our application code. Docker caches this layer.
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

# Now, copy our application code into the container.
COPY ./app /code/app

# Inform Docker that the application will run on port 8000.
EXPOSE 8000

# The default command to run when the container starts.
# We start the server on 0.0.0.0 to make it accessible from outside the container.
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]