-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
50 lines (36 loc) · 926 Bytes
/
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
###########
# BUILDER #
###########
# Base Image
FROM python:3.10 as builder
# Install Requirements
COPY requirements.txt /
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /wheels -r requirements.txt
#########
# FINAL #
#########
# Base Image
FROM python:3.10-slim
# Install curl
RUN apt-get update && apt-get install -y curl
# Create directory for the app user
RUN mkdir -p /home/app
# Create the app user
RUN groupadd app && useradd -g app app
# Create the home directory
ENV HOME=/home/app
ENV APP_HOME=/home/app/web
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
# Install Requirements
COPY --from=builder /wheels /wheels
COPY --from=builder requirements.txt .
RUN pip install --no-cache /wheels/*
# Copy in the Flask code
COPY . $APP_HOME
# Chown all the files to the app user
RUN chown -R app:app $APP_HOME
# Change to the app user
USER app
# run server
CMD gunicorn --log-level=debug -b 0.0.0.0:5000 manage:app