generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
34 lines (24 loc) · 809 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
ARG BASE_IMAGE=python:3.12-slim
FROM $BASE_IMAGE AS base
ARG REQUIREMENTS=requirements-production.txt
# Create a non-root user
RUN adduser --disabled-password app -u 1000 && \
cp /usr/share/zoneinfo/Europe/London /etc/localtime
RUN mkdir /home/app/case_api
WORKDIR /home/app/case_api
COPY requirements/generated/$REQUIREMENTS requirements.txt
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
COPY app ./app
COPY bin ./bin
COPY manage.py ./manage.py
COPY alembic.ini ./alembic.ini
# Change ownership of the working directory to the non-root user
RUN chown -R app:app /home/app
# Cleanup container
RUN rm -rf /var/lib/apt/lists/*
# Switch to the non-root user
USER app
# Expose the fast api port
EXPOSE 8027
CMD ["uvicorn", "app:case_api", "--port", "8027", "--host", "0.0.0.0"]