-
Notifications
You must be signed in to change notification settings - Fork 26
/
Dockerfile
executable file
·154 lines (121 loc) · 4.54 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
######### First stage (build) ############
FROM python:3.10-slim-bookworm AS build
USER root
LABEL maintainer="[email protected]"
# Version should be same as in Definitions.h
LABEL version="2.29.0"
# Try to update image packages
RUN apt-get -q -y update \
&& DEBIAN_FRONTEND=noninteractive apt-get -q -y upgrade \
&& apt-get -q -y install \
cmake \
postgresql \
libcurl4-openssl-dev \
libcairo2-dev \
libxml2-dev \
libgd-dev \
postgresql-server-dev-all \
postgresql-client \
libudunits2-dev \
udunits-bin \
g++ \
m4 \
netcdf-bin \
libnetcdf-dev \
libhdf5-dev \
libproj-dev \
libgdal-dev \
libsqlite3-dev \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install adaguc-server files need for compilation from context
COPY adagucserverEC /adaguc/adaguc-server-master/adagucserverEC
COPY CCDFDataModel /adaguc/adaguc-server-master/CCDFDataModel
COPY hclasses /adaguc/adaguc-server-master/hclasses
COPY cmake /adaguc/adaguc-server-master/cmake
COPY CMakeLists.txt /adaguc/adaguc-server-master/
COPY compile.sh /adaguc/adaguc-server-master/
WORKDIR /adaguc/adaguc-server-master
RUN bash compile.sh
######### Second stage, base image for test and prod ############
FROM python:3.10-slim-bookworm AS base
USER root
# Try to update image packages
RUN apt-get -q -y update \
&& DEBIAN_FRONTEND=noninteractive apt-get -q -y upgrade \
&& apt-get -q -y install \
postgresql-client \
udunits-bin \
netcdf-bin \
libcairo2 \
libgdal-dev \
libcurl4-openssl-dev \
libgd-dev \
libproj-dev \
time \
supervisor \
pgbouncer \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /adaguc/adaguc-server-master
# Upgrade pip and install python requirements.txt
COPY requirements.txt /adaguc/adaguc-server-master/requirements.txt
RUN pip3 install --no-cache-dir --upgrade pip pip-tools setuptools \
&& pip install --no-cache-dir -r requirements.txt
# Install compiled adaguc binaries from stage one
COPY --from=build /adaguc/adaguc-server-master/bin /adaguc/adaguc-server-master/bin
COPY data /adaguc/adaguc-server-master/data
COPY python /adaguc/adaguc-server-master/python
######### Third stage, test ############
# To run the tests against a postgres db, see docs/test_postgesql.md
FROM base AS test
ENV TEST_IN_CONTAINER=1
COPY requirements-dev.txt /adaguc/adaguc-server-master/requirements-dev.txt
RUN pip install --no-cache-dir -r requirements-dev.txt
COPY tests /adaguc/adaguc-server-master/tests
COPY runtests.sh /adaguc/adaguc-server-master/runtests.sh
COPY runtests_psql.sh /adaguc/adaguc-server-master/runtests_psql.sh
# Run adaguc-server functional and regression tests. See also `./doc/developing/testing.md`
RUN bash runtests.sh
# RUN bash runtests_psql.sh
# Create a file indicating that the test succeeded. This file is used in the final stage
RUN echo "TESTSDONE" > /adaguc/adaguc-server-master/testsdone.txt
######### Fourth stage, prod ############
FROM base AS prod
# Set same uid as vivid
RUN useradd -m adaguc -u 1000 && \
# Setup directories
mkdir -p /data/adaguc-autowms && \
mkdir -p /data/adaguc-datasets && \
mkdir -p /data/adaguc-data && \
mkdir -p /adaguc/userworkspace && \
mkdir -p /adaguc/adaguc-datasets-internal && \
chown adaguc: /tmp -R
# Configure
COPY ./Docker/adaguc-server-config-python-postgres.xml /adaguc/adaguc-server-config.xml
COPY ./Docker/start.sh /adaguc/
COPY ./Docker/adaguc-server-*.sh /adaguc/
COPY ./Docker/baselayers.xml /adaguc/adaguc-datasets-internal/baselayers.xml
# Copy pgbouncer and supervisord config files
COPY ./Docker/pgbouncer/ /adaguc/pgbouncer/
COPY ./Docker/supervisord/ /etc/supervisor/conf.d/
COPY ./Docker/run_supervisord.sh /adaguc/run_supervisord.sh
# Set permissions
RUN chmod +x /adaguc/adaguc-server-*.sh && \
chmod +x /adaguc/start.sh && \
chown -R adaguc:adaguc /data/adaguc* /adaguc /adaguc/*
ENV ADAGUC_PATH=/adaguc/adaguc-server-master
ENV PYTHONPATH=${ADAGUC_PATH}/python/python_fastapi_server
# Build and test adaguc python support
WORKDIR /adaguc/adaguc-server-master/python/lib/
RUN python3 setup.py install
RUN bash -c "python3 /adaguc/adaguc-server-master/python/examples/runautowms/run.py && ls result.png"
WORKDIR /adaguc/adaguc-server-master
# This checks if the test stage has ran without issues.
COPY --from=test /adaguc/adaguc-server-master/testsdone.txt /adaguc/adaguc-server-master/testsdone.txt
USER adaguc
# For HTTP
EXPOSE 8080
ENTRYPOINT ["bash", "/adaguc/run_supervisord.sh"]