-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (24 loc) · 968 Bytes
/
Dockerfile
File metadata and controls
40 lines (24 loc) · 968 Bytes
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
FROM python:3.11-alpine as requirements-stage
ENV VERSION 0.1.0
WORKDIR /tmp
RUN apk add --no-cache gcc musl-dev libffi-dev openssl-dev && \
pip install poetry && \
poetry config virtualenvs.create false
COPY ./pyproject.toml ./poetry.lock* /tmp/
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes
FROM python:3.11-alpine
# Create a non-root user
RUN adduser --disabled-password --gecos '' appuser
WORKDIR /MovieAPI
COPY --from=requirements-stage /tmp/requirements.txt /MovieAPI/requirements.txt
RUN apk add --no-cache libffi openssl && \
pip install --no-cache-dir --upgrade -r /MovieAPI/requirements.txt && \
rm -rf /root/.cache && \
rm -rf /var/cache/apk/*
COPY ./MovieAPI /MovieAPI/
# Change ownership of the app directory to the non-root user
RUN chown -R appuser:appuser /MovieAPI
USER appuser
WORKDIR /
ENV PORT=8000
CMD ["uvicorn", "MovieAPI.main:app", "--host", "0.0.0.0", "--port", "${PORT}"]