-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
56 lines (37 loc) · 1.18 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
55
56
# BASE
FROM python:3.10-slim-buster AS base
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1
RUN echo "Base python image ready"
# DEPENDENCIES
FROM base AS dependencies
RUN echo "Installing dependencies on base"
RUN apt update && apt install -y git curl gcc libexpat1 bash
COPY requirements.txt .
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN /opt/venv/bin/python3 -m pip install --upgrade pip && \
pip uninstall -y licenseware && \
pip install -r requirements.txt
RUN echo "Done!"
# RUNABLE APP
FROM dependencies AS run
RUN echo "Preparing the app"
ARG PORT=5000
ARG APP_DIR=/app
ARG USER=licenseware
ARG FILE_UPLOAD_PATH=/tmp/lware
WORKDIR ${APP_DIR}
RUN useradd -m ${USER} && \
mkdir -p ${FILE_UPLOAD_PATH} && \
chown ${USER}:${USER} ${FILE_UPLOAD_PATH}
ENV PYTHONPATH=/app/site-packages
COPY --from=dependencies /opt/venv/lib/python3.10/site-packages /app/site-packages
COPY . .
RUN echo '\nHere are the files copied:\n' && dir -s && echo '\nMake sure to inclue a Procfile and start the app with honcho start\n'
EXPOSE ${PORT}
VOLUME ${FILE_UPLOAD_PATH}
USER ${USER}
RUN echo "Ready!"