-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
60 lines (43 loc) · 1.4 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
57
58
59
60
# # # # # # # # # # # # # # # #
# Run the app on Python 3.9.X #
# # # # # # # # # # # # # # # #
# # # # # # # # # # # # #
# Starting the builder #
# # # # # # # # # # # # #
# pull official base image Python 3.9.X
FROM python:3.9-slim-buster as builder
# set the working directory
WORKDIR /usr/workspace/emp_dms
# install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends gcc
# install python dependencies
COPY ./requirements.txt .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/workspace/emp_dms/wheels -r requirements.txt
# # # # # # # # # # # # # #
# Starting the final step #
# # # # # # # # # # # # # #
# pull official base image Python 3.9.X
FROM python:3.9-slim-buster
# create dierctory for the app user
RUN mkdir -p /home/app
# create the app user
RUN addgroup --system app && adduser --system --group app
# create the appropiate directories
ENV HOME=/home/app
ENV APP_HOME=/home/app/employee_dms
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
# install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends netcat
COPY --from=builder /usr/workspace/emp_dms/wheels /wheels
COPY --from=builder /usr/workspace/emp_dms/requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache /wheels/*
# copy project
COPY . $APP_HOME
EXPOSE 80
RUN chown -R app:app $APP_HOME
RUN chmod +x $APP_HOME/flask.init.sh
USER app
CMD ["./flask.init.sh"]