forked from squidgetx/arklet
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
69 lines (54 loc) · 1.89 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
61
62
63
64
65
66
67
68
69
# Multi-stage unique docker build script, provides both dev & prod environments
# ----------------------------------------------------
# Base-image
# ----------------------------------------------------
FROM python:3.9-slim-buster as common-base
# Django directions: https://blog.ploetzli.ch/2020/efficient-multi-stage-build-django-docker/
# Pip on docker : https://pythonspeed.com/articles/multi-stage-docker-python/
# https://blog.mikesir87.io/2018/07/leveraging-multi-stage-builds-single-dockerfile-dev-prod/
# https://pythonspeed.com/articles/base-image-python-docker-images/
# Default environment: Dev
ARG ENV=dev
ENV PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100
ENV HOST=0.0.0.0 \
PORT=8000
WORKDIR /app
COPY ./docker/install-packages.sh .
RUN ./install-packages.sh
# ----------------------------------------------------
# Install dependencies
# ----------------------------------------------------
FROM common-base AS app-run
ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt /app/
COPY ./ark ./ark
COPY ./ark_import ./ark_import
COPY ./arklet ./arklet
COPY ./manage.py ./manage.py
COPY ./docker/entrypoint.sh ./entrypoint.sh
RUN pip install -r requirements.txt
# ----------------------------------------------------
# Run Dev
# ----------------------------------------------------
FROM app-run AS dev
ENV ENV="dev" \
ARKLET_DEBUG="True"
CMD ["bash"]
# ----------------------------------------------------
# Run Prod
# ----------------------------------------------------
FROM app-run AS prod
ENV ENV="prod" \
ARKLET_DEBUG="False"
CMD ["./entrypoint.sh"]
# # For some _real_ performance, at cost of ease of use:
# FROM python:3.9-alpine as prod
# ENV PATH="/opt/venv/bin:$PATH"
# COPY . .
# RUN apk add python3-dev build-base linux-headers pcre-dev
# RUN pip install uwsgi