-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
54 lines (41 loc) · 1.26 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
##### Builder Stage #####
FROM python:3.11-slim as builder
# Set default path
ENV PATH="/app/.venv/bin:${PATH}"
# Set default workdir
WORKDIR /app
# Create virtualenv and install Python packages
RUN pip install --no-cache-dir pip -U && \
pip install --no-cache-dir poetry && \
poetry config virtualenvs.in-project true
COPY ./poetry.lock poetry.lock
COPY ./pyproject.toml pyproject.toml
RUN poetry install --only main
# Copy app files and add directory to workdir
COPY fastqueue ./fastqueue
COPY alembic ./alembic
##### Final Stage #####
FROM python:3.11-slim
# Disable Prompt During Packages Installation
ARG DEBIAN_FRONTEND=noninteractive
# Set default path
ENV PATH="/app/.venv/bin:${PATH}"
ENV PYTHONPATH /app
# Copy content from builder stage
COPY --from=builder /app /app
# Install packages
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install --no-install-recommends -y tini && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Add fastqueue user and create directories
RUN useradd -m fastqueue && mkdir -p /app
# Set permissions
RUN chown -R fastqueue:fastqueue /app
# Set workdir and XAPO User
WORKDIR /app
USER fastqueue
# Set entrypoint and cmd
ENTRYPOINT ["/usr/bin/tini", "--", "python", "/app/fastqueue/main.py"]
CMD ["server"]