-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (27 loc) · 936 Bytes
/
Dockerfile
File metadata and controls
37 lines (27 loc) · 936 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
# pull base image
FROM python:3.8-alpine
# adding unpriviledged user and group
RUN addgroup -S messaging_api -g 433 && \
adduser -u 431 -s /bin/sh -G messaging_api -D messaging_api
# Giving ownership of logs to messaging_api user
RUN mkdir /var/log/messaging_api
RUN chown messaging_api:messaging_api /var/log/messaging_api
#set working directory
WORKDIR /usr/src/app
# add and install requirements
COPY ./requirements.txt /usr/src/app/requirements.txt
RUN pip install -r requirements.txt
# add source code
COPY app /usr/src/app/
# set environment variables
# prevents Python from writing .pyc files to disk
ENV PYTHONDONTWRITEBYTECODE 1
# prevents Python from buffering stdout and stderr
ENV PYTHONUNBUFFERED 1
#Adding unpriviledged user
USER messaging_api
# configure Flask environment variables
ENV FLASK_APP /usr/src/app/app/messaging_api.py
ENV FLASK_ENV production
# running flask server
CMD flask run --host=0.0.0.0