-
Notifications
You must be signed in to change notification settings - Fork 37
/
Dockerfile
81 lines (69 loc) · 3.05 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
# Note that this is now pinned to a fixed version. Remember to check for new versions periodically.
FROM ghcr.io/osgeo/gdal:ubuntu-small-3.9.3 AS builder
# Environment is test or deployment.
ARG ENVIRONMENT=deployment
# Setup build env for postgresql-client-16
USER root
RUN apt-get update -y \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --fix-missing --no-install-recommends \
git \
# For Psycopg2
libpq-dev python3-dev \
gcc \
python3-pip \
postgresql-client-16 \
# For Pyproj build \
proj-bin libproj-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /var/dpkg/* /var/tmp/* /var/log/dpkg.log
WORKDIR /build
RUN python3 -m pip --disable-pip-version-check -q wheel --no-binary psycopg2 psycopg2 \
&& ([ "$ENVIRONMENT" = "deployment" ] || \
python3 -m pip --disable-pip-version-check -q wheel --no-binary pyproj pyproj)
# Should match builder base.
FROM ghcr.io/osgeo/gdal:ubuntu-small-3.9.3
# Environment is test or deployment.
ARG ENVIRONMENT=deployment
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update -y \
&& apt-get install -y --no-install-recommends \
git \
gosu \
python3-pip \
tini \
&& ([ "$ENVIRONMENT" = "deployment" ] || \
apt-get install -y --no-install-recommends \
proj-bin) \
&& apt-get upgrade -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /var/dpkg/* /var/tmp/* /var/log/dpkg.log
# Add login-script for UID/GID-remapping.
COPY --chown=root:root --link docker/files/remap-user.sh /usr/local/bin/remap-user.sh
# Copy source code and install it
WORKDIR /src
COPY . /src
## Only install pydev requirements if arg PYDEV_DEBUG is set to 'yes'
ARG PYDEV_DEBUG="no"
COPY --from=builder --link /build/*.whl ./
RUN EXTRAS=$([ "$ENVIRONMENT" = "deployment" ] || echo ",test") && \
python3 -m pip --disable-pip-version-check install ./*.whl --break-system-packages && \
rm ./*.whl && \
echo "version=\"$(python3 setup.py --version)\"" > datacube_ows/_version.py && \
python3 -m pip --disable-pip-version-check install --no-cache-dir ".[ops$EXTRAS]" --break-system-packages && \
([ "$PYDEV_DEBUG" != "yes" ] || \
python3 -m pip --disable-pip-version-check install --no-cache-dir .[dev] --break-system-packages) && \
python3 -m pip freeze && \
([ "$ENVIRONMENT" != "deployment" ] || \
(rm -rf /src/* /src/.git* && \
apt-get purge -y \
git \
git-man \
python3-pip))
# Configure user
WORKDIR "/home/ubuntu"
ENV GDAL_DISABLE_READDIR_ON_OPEN="EMPTY_DIR" \
CPL_VSIL_CURL_ALLOWED_EXTENSIONS=".tif, .tiff" \
GDAL_HTTP_MAX_RETRY="10" \
GDAL_HTTP_RETRY_DELAY="1"
ENTRYPOINT ["/usr/local/bin/remap-user.sh"]
CMD ["gunicorn", "-b", "0.0.0.0:8000", "--workers=3", "-k", "gevent", "--timeout", "121", "--pid", "/home/ubuntu/gunicorn.pid", "--log-level", "info", "--worker-tmp-dir", "/dev/shm", "--config", "python:datacube_ows.gunicorn_config", "datacube_ows.wsgi"]