-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
165 lines (140 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
155
156
157
158
159
160
161
162
163
164
165
# - Create 'build and test' image -
FROM ubuntu:20.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install dependencies
RUN apt-get update -qq \
&& apt-get install --no-install-recommends -y \
autoconf \
automake \
ca-certificates \
expat \
fcgiwrap \
g++ \
git \
libexpat1-dev \
libbz2-dev \
libcereal-dev \
libfcgi-dev \
libfmt-dev \
libgoogle-perftools-dev \
libicu-dev \
liblz4-dev \
libpcre2-dev \
libtool \
libxml2-dev \
make \
zlib1g-dev \
&& update-ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Clone mmd-osm/Overpass-API repository
RUN git clone --depth 1 https://github.com/mmd-osm/Overpass-API.git overpass \
&& cd overpass \
&& git submodule init \
&& git submodule update \
&& cd ..
# Change working directory
WORKDIR /overpass
# Compile sources
RUN cd src/ \
&& chmod u+x test-bin/*.sh \
&& autoscan \
&& aclocal \
&& autoheader \
&& libtoolize \
&& automake --add-missing \
&& autoconf \
&& cd .. \
&& mkdir -p build \
&& cd build \
&& ../src/configure \
CXXFLAGS="-D_FORTIFY_SOURCE=2 -fexceptions -fpie -Wl,-pie -fpic -shared -fstack-protector-strong -Wl,--no-as-needed -pipe -Wl,-z,defs -Wl,-z,now -Wl,-z,relro -fno-omit-frame-pointer -flto -fwhole-program -O2" \
LDFLAGS="-ltcmalloc -flto -fwhole-program -lfmt" \
--prefix=/root/overpass \
--enable-lz4 \
--enable-fastcgi \
--enable-tests
# Build and install binaries
RUN cd build \
&& make V=0 -j3 \
&& make install \
&& cp -R test-bin/ bin/ cgi-bin/ ../src \
&& export PATH=$PATH:/root/overpass/bin:/root/overpass/cgi-bin:/root/overpass/test-bin
# Run tests
RUN cd osm-3s_testing/ \
&& ../src/test-bin/run_testsuite.sh 200 notimes
# Compile export tool for database files
RUN cd src/ \
&& make V=0 -j3 bin/export_tables \
&& strip bin/export_tables \
&& cp bin/export_tables /root/overpass/bin/export_tables_0756 \
&& cd ..
# --------------------------------------------------------------------------------------------------------------
# - Create final image -
FROM nginx:1.21
# Install dependencies
RUN apt-get update -qq \
&& apt-get install --no-install-recommends -y \
bash \
bzip2 \
curl \
expat \
fcgiwrap \
git \
jq \
libfcgi-bin \
liblz4-1 \
libgomp1 \
libgoogle-perftools4 \
libpcre2-8-0 \
nginx \
osmium-tool \
python3 \
python3-venv \
supervisor \
wget \
zlib1g \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN wget http://archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu66_66.1-2ubuntu2_amd64.deb \
&& dpkg -i libicu66_66.1-2ubuntu2_amd64.deb \
&& rm libicu66_66.1-2ubuntu2_amd64.deb
# Copy binaries and rules
COPY --from=builder /root/overpass/bin /opt/overpass/bin
COPY --from=builder /root/overpass/cgi-bin /opt/overpass/cgi-bin
COPY --from=builder /overpass/src/rules /opt/overpass/rules
# Create overpass user
RUN addgroup overpass \
&& adduser --home /db --disabled-password --gecos overpass --ingroup overpass overpass
# Clone lhbelfanti/overpass-api repository
RUN git clone --depth 1 https://github.com/lhbelfanti/overpass-api scripts \
&& cd scripts
# Install python dependencies
COPY requirements.txt /opt/overpass/
RUN python3 -m venv /opt/overpass/venv \
&& /opt/overpass/venv/bin/pip install -r /opt/overpass/requirements.txt --only-binary osmium
# Create necessary folders for the database initialization
RUN mkdir -p /db/diffs \
/opt/overpass/etc \
/nginx \
/docker-entrypoint-initdb.d
RUN chown nginx:nginx /nginx \
&& chown -R overpass:overpass /db
# Copy configuration files
COPY etc/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY etc/nginx-overpass.conf.template /etc/nginx/nginx.conf.template
# Copy scripts files and give them permissions
COPY bin/update_overpass.sh \
bin/update_overpass_loop.sh \
bin/rules_loop.sh \
bin/dispatcher_start.sh \
bin/start_fcgiwrap.sh \
/opt/overpass/bin/
COPY docker-entrypoint.sh docker-healthcheck.sh /opt/overpass/
RUN chmod a+rx /opt/overpass/docker-entrypoint.sh \
/opt/overpass/bin/update_overpass.sh \
/opt/overpass/bin/rules_loop.sh \
/opt/overpass/bin/dispatcher_start.sh \
/opt/overpass/bin/start_fcgiwrap.sh
EXPOSE 80
CMD ["/opt/overpass/docker-entrypoint.sh"]