Dockerfile 1.01 KB
Newer Older
1 2
# ==================================== BASE ====================================
ARG INSTALL_PYTHON_VERSION=${INSTALL_PYTHON_VERSION:-3.7}
3
FROM python:${INSTALL_PYTHON_VERSION}-slim-buster AS base
4
ENV CONFIG_FILE_PATH=${CONFIG_FILE_PATH:-'/etc/run_config/RUN_CONFIG.yml'}
5
ENV GUNICORN_CONFIG_FILE_PATH=${GUNICORN_CONFIG_FILE_PATH:-'/etc/gunicorn_config/GUNICORN_CONFIG.py'}
6 7 8

RUN apt-get update
RUN apt-get install -y \
9 10 11
    curl \
    netcat \
    iputils-ping \
12 13
    ssh \
    build-essential \
David Mendez's avatar
David Mendez committed
14
    libpq-dev
15

David Mendez's avatar
David Mendez committed
16 17
WORKDIR /app
COPY requirements.txt .
18 19

RUN useradd -m glados -u 2892
David Mendez's avatar
David Mendez committed
20
RUN chown -R glados:glados /app
21 22
USER glados
ENV PATH="/home/glados/.local/bin:${PATH}"
David Mendez's avatar
David Mendez committed
23 24 25 26

RUN pip install --user -r requirements.txt
COPY . .

27
FROM base AS development-server
David Mendez's avatar
David Mendez committed
28
ENTRYPOINT FLASK_APP=app flask run --host=0.0.0.0
29

30
FROM base AS production-server
31 32
# Take into account that the app will get the configuration from the variable DELAYED_JOBS_RAW_CONFIG if the config.yml
# file is not found.
33
ENTRYPOINT gunicorn wsgi:FLASK_APP -c ${GUNICORN_CONFIG_FILE_PATH}