-
Notifications
You must be signed in to change notification settings - Fork 32
/
Dockerfile
91 lines (79 loc) · 2.6 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
FROM ghcr.io/osgeo/gdal:ubuntu-small-3.9.1 AS builder
ENV DEBIAN_FRONTEND=noninteractive \
LC_ALL=C.UTF-8 \
LANG=C.UTF-8 \
PYTHONFAULTHANDLER=1
# Apt installation
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
build-essential \
git \
# For Psycopg2
libpq-dev \
python3-dev \
python3-pip
WORKDIR /build
RUN python3 -m pip --disable-pip-version-check -q wheel --no-binary psycopg2 psycopg2
FROM ghcr.io/osgeo/gdal:ubuntu-small-3.9.1
ENV DEBIAN_FRONTEND=noninteractive \
LC_ALL=C.UTF-8 \
LANG=C.UTF-8 \
PYTHONFAULTHANDLER=1
# Environment can be whatever is supported by setup.py
# so, either deployment, test
ARG ENVIRONMENT=deployment
# ARG ENVIRONMENT=test
# Apt installation
# git: required by setuptools_scm.
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
git \
# For Psycopg2
libpq5 \
tini \
postgresql-client \
python3-pip \
&& apt-get autoclean && \
apt-get autoremove && \
rm -rf /var/lib/{apt,dpkg,cache,log} && \
echo "Environment is: $ENVIRONMENT" && \
([ "$ENVIRONMENT" = "deployment" ] || \
pip install --disable-pip-version-check pip-tools pytest-cov --break-system-packages)
# Set up a nice workdir and add the live code
ENV APPDIR=/code
WORKDIR $APPDIR
COPY . $APPDIR
# These ENVIRONMENT flags make this a bit complex, but basically, if we are in dev
# then we want to link the source (with the -e flag) and if we're in prod, we
# want to delete the stuff in the /code folder to keep it simple.
COPY --from=builder --link /build/*.whl ./
RUN python3 -m pip --disable-pip-version-check -q install *.whl --break-system-packages && \
rm *.whl && \
([ "$ENVIRONMENT" = "deployment" ] || \
pip --disable-pip-version-check install --editable .[$ENVIRONMENT] --break-system-packages) && \
([ "$ENVIRONMENT" != "deployment" ] || \
(pip --no-cache-dir --disable-pip-version-check install .[$ENVIRONMENT] --break-system-packages && \
rm -rf /code/* /code/.git*)) && \
pip freeze && \
([ "$ENVIRONMENT" != "deployment" ] || \
apt-get remove -y \
git \
git-man \
python3-pip)
ENTRYPOINT ["/bin/tini", "--"]
# This is for prod, and serves as docs. It's usually overwritten
CMD ["gunicorn", \
"-b", \
"0.0.0.0:8080", \
"-w", \
"3", \
"--threads=2", \
"-k", \
"gthread", \
"--timeout", \
"90", \
"--config", \
"python:cubedash.gunicorn_config", \
"cubedash:create_app()"]