-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (36 loc) · 1.17 KB
/
Dockerfile
File metadata and controls
44 lines (36 loc) · 1.17 KB
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
# Use Debian-based Python base image
FROM python:3.8.0-slim-buster
# Install dependencies
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y netcat-openbsd gcc && \
# OpenCV dependencies
apt-get install -y libglib2.0-0 libsm6 libxext6 && \
apt-get install -y libglib2.0-0 libxrender1 libfontconfig1 && \
# Pillow dependencies
apt-get install -y libjpeg-dev zlib1g-dev && \
apt-get clean
# Create + set working directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Set envirovars
# Prevent pyc files
ENV PYTHONDONTWRITEBYTECODE 1
# Prevents buffering stdout and sdterr
ENV PYTHONUNBUFFERED 1
ENV FLASK_ENV production
ENV APP_SETTINGS detect.config.ProductionConfig
# Add and run as non-root user
RUN addgroup --system tpds && adduser --system --no-create-home --group tpds
RUN chown -R tpds:tpds /usr/src/app && chmod -R 755 /usr/src/app
# Add and install dependencies
RUN pip install --upgrade pip
COPY ./requirements.txt /usr/src/app/requirements.txt
RUN pip install -r requirements.txt
# Switch to non-root user
USER tpds
# Add app
COPY . /usr/src/app
# Run the gunicorn server
EXPOSE 5000
CMD gunicorn --bind 0.0.0.0:5000 manage:app