Statistics
| Branch: | Revision:

collecting_society_docker / services / build / Dockerfile @ 7cd7f683

History | View | Annotate | Download (12.3 KB)

1
ARG ENVIRONMENT
2
ARG WORKDIR
3
ARG APT_CACHERURL
4
ARG DEBIAN
5
ARG DEBUGGER_WINPDB
6
ARG DEBUGGER_PTVSD
7

    
8

    
9
#==============================================================================
10
# Base Images (Jessie)
11
#==============================================================================
12

    
13
#--- BASE ---------------------------------------------------------------------
14

    
15
### production
16
FROM debian:jessie-slim AS jessie_base_production
17
# set workdir
18
ARG WORKDIR
19
ENV WORKDIR $WORKDIR
20
ENV PATH $PATH:$WORKDIR
21
RUN mkdir -p $WORKDIR
22
WORKDIR $WORKDIR
23
# configure apt
24
ENV DEBIAN_FRONTEND noninteractive
25
ARG APT_CACHERURL
26
RUN if [ ${APT_CACHERURL} ]; then \
27
        echo "Acquire::HTTP::Proxy ${APT_CACHERURL};" >> /etc/apt/apt.conf.d/01proxy \
28
        && echo 'Acquire::HTTPS::Proxy "false";' >> /etc/apt/apt.conf.d/01proxy; \
29
    fi
30
# install base packages
31
RUN apt-get update && apt-get install -y --no-install-recommends \
32
        locales \
33
        ssl-cert \
34
        ca-certificates \
35
        libmagic1 \
36
    && rm -rf /var/lib/apt/lists/*
37
# configure language
38
RUN localedef -i en_US -f UTF-8 en_US.UTF-8
39
ENV LANGUAGE en_US.UTF-8
40
ENV LANG en_US.UTF-8
41
ENV LC_ALL en_US.UTF-8
42

    
43
### testing
44
FROM jessie_base_production AS jessie_base_testing
45

    
46
### development
47
FROM jessie_base_testing AS jessie_base_development
48
# install development packages
49
RUN apt-get update && apt-get install -y --no-install-recommends \
50
    && apt-get install -y --no-install-recommends \
51
        git \
52
        htop \
53
        iputils-ping \
54
        net-tools \
55
        vim \
56
    && rm -rf /var/lib/apt/lists/*
57

    
58
### result
59
FROM jessie_base_${ENVIRONMENT} AS jessie_base
60

    
61

    
62
#--- base -> PYTHON -----------------------------------------------------------
63

    
64
### production
65
FROM jessie_base AS jessie_python_production
66
# install python
67
ENV PYTHONUNBUFFERED 1
68
RUN apt-get update && apt-get install -y --no-install-recommends \
69
    && apt-get install -y --no-install-recommends \
70
        curl \
71
        python \
72
    && rm -rf /var/lib/apt/lists/*
73
# install pip
74
RUN curl -s https://bootstrap.pypa.io/get-pip.py | python
75
# create virtual environment
76
RUN pip install virtualenv
77
RUN python -m virtualenv /opt/venv
78
ENV PATH="/opt/venv/bin:$PATH"
79
ENV VIRTUAL_ENV=/opt/venv
80

    
81
### testing
82
FROM jessie_python_production AS jessie_python_testing
83

    
84
### development
85
FROM jessie_python_testing AS jessie_python_development
86

    
87
### result
88
FROM jessie_python_${ENVIRONMENT} AS jessie_python
89

    
90

    
91
#--- base -> python -> TRYTOND ------------------------------------------------
92

    
93
### production
94
FROM jessie_python AS jessie_trytond_production
95
# install database packages
96
RUN for i in $(seq 1 8); do mkdir -p "/usr/share/man/man${i}"; done \
97
    && apt-get update && apt-get install -y --no-install-recommends \
98
        postgresql-client-9.4  \
99
        sqlite3 \
100
        libxslt1.1 \
101
    && rm -rf /var/lib/apt/lists/* \
102
    && rm -rf /usr/share/man/*
103

    
104
### testing
105
FROM jessie_trytond_production AS jessie_trytond_testing
106

    
107
### development
108
FROM jessie_trytond_testing AS jessie_trytond_development
109

    
110
### result
111
FROM jessie_trytond_${ENVIRONMENT} AS jessie_trytond
112

    
113

    
114
#--- base -> python -> ECHOPRINT ----------------------------------------------
115

    
116
### production
117
FROM jessie_python AS jessie_echoprint_production
118
RUN for i in $(seq 1 8); do mkdir -p "/usr/share/man/man${i}"; done \
119
    && apt-get update && apt-get install -y --no-install-recommends \
120
        default-jre \
121
    && rm -rf /var/lib/apt/lists/* \
122
    && rm -rf /usr/share/man/*
123
RUN mkdir /opt/echoprint-data
124
COPY fingerprint.sh /bin/fingerprint
125
RUN chmod u+x /bin/fingerprint
126
COPY fingerprint-data.json /root/fingerprint-data.json
127

    
128
### testing
129
FROM jessie_echoprint_production AS jessie_echoprint_testing
130

    
131
### development
132
FROM jessie_echoprint_testing AS jessie_echoprint_development
133

    
134
### result
135
FROM jessie_echoprint_${ENVIRONMENT} AS jessie_echoprint
136

    
137

    
138
#--- base -> python -> WORKER -------------------------------------------------
139

    
140
### production
141
FROM jessie_python AS jessie_worker_production
142
RUN apt-get update && apt-get install -y --no-install-recommends \
143
        cron \
144
        libav-tools \
145
        libtag1-vanilla \
146
    && rm -rf /var/lib/apt/lists/*
147
RUN ln -s /usr/bin/avconv /usr/local/bin/ffmpeg
148

    
149
### testing
150
FROM jessie_worker_production AS jessie_worker_testing
151
# install database packages
152
RUN for i in $(seq 1 8); do mkdir -p "/usr/share/man/man${i}"; done \
153
    && apt-get update && apt-get install -y --no-install-recommends \
154
        postgresql-client-9.4  \
155
    && rm -rf /var/lib/apt/lists/* \
156
    && rm -rf /usr/share/man/*
157

    
158
### development
159
FROM jessie_worker_testing AS jessie_worker_development
160

    
161
### result
162
FROM jessie_worker_${ENVIRONMENT} AS jessie_worker
163

    
164

    
165
#--- base -> python -> COMPILE ------------------------------------------------
166

    
167
FROM jessie_python AS jessie_compile
168
# install libs
169
RUN apt-get update && apt-get install -y --no-install-recommends \
170
        build-essential \
171
        git \
172
        python-dev \
173
        # pip: lxml \
174
            libxml2-dev \
175
            libxslt-dev \
176
        # pip: psycopg2 \
177
            libpq-dev \
178
        # pip: pyOpenSSL \
179
            libssl-dev \
180
            libffi-dev \
181
        # pip: pytaglib \
182
            libtag1-dev \
183
        # echoprint-codegen \
184
            libboost-dev \
185
            zlib1g-dev \
186
        # echoprint-server
187
            libbz2-dev \
188
            wget \
189
    && rm -rf /var/lib/apt/lists/*
190

    
191

    
192
#==============================================================================
193
# Compilation Images
194
#==============================================================================
195

    
196
#--- [COMPILE] PYTHON ---------------------------------------------------------
197

    
198
### production
199
FROM jessie_compile AS jessie_python_production_compiled
200
RUN pip install \
201
    click==4.0
202

    
203
### testing
204
FROM jessie_python_production_compiled AS jessie_python_testing_compiled
205
RUN pip install \
206
    coverage==4.5.1 \
207
    click==4.0 \
208
    nose==1.3.7 \
209
    nose2==0.9.1 \
210
    pytest==4.6.5 \
211
    tox==3.14.0
212

    
213
### development
214
FROM jessie_python_testing_compiled AS jessie_python_development_compiled
215
RUN pip install \
216
    pdbpp==0.9.2 \
217
    sphinx==1.8.5
218
ARG DEBUGGER_PTVSD
219
RUN if [ ${DEBUGGER_PTVSD} -ne 0 ]; then pip install \
220
        ptvsd==4.3.2; \
221
    fi
222
ARG DEBUGGER_WINPDB
223
RUN if [ ${DEBUGGER_WINPDB} -ne 0 ]; then pip install \
224
        winpdb==1.3.6; \
225
    fi
226

    
227
### result
228
FROM jessie_python_${ENVIRONMENT}_compiled AS jessie_python_compiled
229

    
230
#--- [COMPILE] python -> ECHOPRINT --------------------------------------------
231

    
232
### production
233
FROM jessie_python_compiled AS jessie_echoprint_production_compiled
234

    
235
# install tokyo cabinet (from https://github.com/jon-eckstein/docker-echoprint-server)
236
RUN wget https://fallabs.com/tokyocabinet/tokyocabinet-1.4.48.tar.gz
237
RUN tar xvf tokyocabinet-1.4.48.tar.gz
238
RUN mkdir /opt/tokyocabinet/
239
RUN cd tokyocabinet-1.4.48 && ./configure --prefix=/opt/tokyocabinet/ && make && make install
240

    
241
# install tokyo tyrant
242
RUN wget https://fallabs.com/tokyotyrant/tokyotyrant-1.1.41.tar.gz
243
RUN tar xvf tokyotyrant-1.1.41.tar.gz
244
RUN mkdir /opt/tokyotyrant
245
RUN cd tokyotyrant-1.1.41 && ./configure --prefix=/opt/tokyotyrant/ --with-tc=/opt/tokyocabinet && make && make install
246

    
247
# install python packages
248
RUN pip install \
249
    web.py==0.40 \
250
    pyechonest==9.0.0
251

    
252
### testing
253
FROM jessie_echoprint_production_compiled AS jessie_echoprint_testing_compiled
254

    
255
### development
256
FROM jessie_echoprint_testing_compiled AS jessie_echoprint_development_compiled
257

    
258
### result
259
FROM jessie_echoprint_${ENVIRONMENT}_compiled AS jessie_echoprint_compiled
260

    
261
#--- [COMPILE] python -> TRYTOND ----------------------------------------------
262

    
263
### production
264
FROM jessie_python_compiled AS jessie_trytond_production_compiled
265
# trytond mandatory
266
RUN pip install \
267
    lxml==3.4.0 \
268
    polib==1.0.5 \
269
    python-dateutil==2.2 \
270
    python-sql==0.4 \
271
    relatorio==0.6.1
272
# trytond optional
273
RUN pip install \
274
    "proteus<3.5.0" \
275
    interlude==1.3.1 \
276
    mock==1.0.1 \
277
    py-bcrypt==0.4 \
278
    psycopg2==2.5.4 \
279
    pydot==1.4.1 \
280
    python-Levenshtein==0.11.2 \
281
    PyWebDAV==0.9.8 \
282
    simplejson==3.6.5
283
# additional
284
RUN pip install \
285
    hurry.filesize==0.9 \
286
    pyOpenSSL==17.5.0 \
287
    pytz==2015.7 \
288
    vatnumber==1.2
289

    
290
### testing
291
FROM jessie_trytond_production_compiled AS jessie_trytond_testing_compiled
292

    
293
### development
294
FROM jessie_trytond_testing_compiled AS jessie_trytond_development_compiled
295

    
296
### result
297
FROM jessie_trytond_${ENVIRONMENT}_compiled AS jessie_trytond_compiled
298

    
299

    
300
#--- [COMPILE] python -> trytond -> PYRAMID -----------------------------------
301

    
302
### production
303
FROM jessie_trytond_compiled AS jessie_pyramid_production_compiled
304
RUN pip install \
305
    colander==1.4 \
306
    cornice==3.4.0 \
307
    cornice-swagger==0.7.0 \
308
    cryptacular==1.4.1 \
309
    Pillow==6.0.0 \
310
    deform==2.0.5 \
311
        # 29.5.18: requirement of deform 2.0.5 not handled automaticly
312
        "iso8601<0.1.12" \
313
    pyramid==1.9.2 \
314
    pyramid-beaker==0.8 \
315
    pyramid-chameleon==0.3 \
316
    pyramid-mailer==0.15.1 \
317
    python-magic==0.4.15 \
318
    raven==6.10.0 \
319
    requests==2.18.4 \
320
    waitress==1.1.0
321

    
322
### testing
323
FROM jessie_pyramid_production_compiled AS jessie_pyramid_testing_compiled
324
RUN pip install \
325
    selenium==3.12.0 \
326
    WebTest==2.0.29
327

    
328
### development
329
FROM jessie_pyramid_testing_compiled AS jessie_pyramid_development_compiled
330
RUN pip install \
331
    pyramid-debugtoolbar==4.4
332

    
333
### result
334
FROM jessie_pyramid_${ENVIRONMENT}_compiled AS jessie_pyramid_compiled
335

    
336

    
337
#--- [COMPILE] python -> WORKER -----------------------------------------------
338

    
339
### production
340
FROM jessie_python_compiled AS jessie_worker_production_compiled
341
# compile echoprint-codegen
342
RUN git clone https://github.com/spotify/echoprint-codegen.git /opt/echoprint-codegen \
343
    && git -C /opt/echoprint-codegen checkout v4.12 \
344
    && make -C /opt/echoprint-codegen/src \
345
    && chmod 755 /opt/echoprint-codegen/echoprint-codegen
346
# install pip packages
347
RUN pip install  \
348
    "proteus<3.5.0" \
349
    pyechonest==9.0.0  \
350
    pydub==0.18.0  \
351
    pytaglib==1.4.1  \
352
    requests==2.9.1
353

    
354
### testing
355
FROM jessie_worker_production_compiled AS jessie_worker_testing_compiled
356

    
357
### development
358
FROM jessie_worker_testing_compiled AS jessie_worker_development_compiled
359

    
360
### result
361
FROM jessie_worker_${ENVIRONMENT}_compiled AS jessie_worker_compiled
362

    
363

    
364
#==============================================================================
365
# Service Images
366
#==============================================================================
367

    
368
#--- DATABASE -----------------------------------------------------------------
369

    
370
FROM postgres:12.1 AS database
371

    
372

    
373
#--- WEBSERVER ----------------------------------------------------------------
374

    
375
FROM jwilder/nginx-proxy AS webserver
376
RUN { \
377
      echo 'client_max_body_size 100m;'; \
378
      echo 'error_log off;'; \
379
    } > /etc/nginx/conf.d/my_proxy.conf
380

    
381

    
382
#--- BROWSER ------------------------------------------------------------------
383

    
384
FROM selenium/standalone-firefox AS browser
385

    
386

    
387
#--- base -> python -> FINGERPRINTING -----------------------------------------
388

    
389
FROM ${DEBIAN}_echoprint AS fingerprint
390
COPY --from=jessie_echoprint_compiled /opt/tokyocabinet/bin/* /bin/
391
COPY --from=jessie_echoprint_compiled /opt/tokyocabinet/lib/libtokyocabinet.* /lib/
392
COPY --from=jessie_echoprint_compiled /opt/tokyotyrant/bin/* /bin/
393
COPY --from=jessie_echoprint_compiled /opt/tokyotyrant/lib/libtokyotyrant.* /lib/
394
COPY --from=jessie_echoprint_compiled /opt/tokyotyrant/lib/ttskel* /lib/
395
COPY --from=jessie_echoprint_compiled /opt/venv /opt/venv
396

    
397

    
398
#--- base -> python -> WORKER -------------------------------------------------
399

    
400
FROM ${DEBIAN}_worker AS worker
401
COPY --from=jessie_worker_compiled /opt/echoprint-codegen/echoprint-codegen /usr/local/bin/echoprint-codegen
402
COPY --from=jessie_worker_compiled /opt/venv /opt/venv
403
COPY worker.cron /etc/cron.d/worker
404

    
405

    
406
#--- base -> python -> trytond -> ERPSERVER -----------------------------------
407

    
408
FROM ${DEBIAN}_trytond AS erpserver
409
COPY --from=jessie_trytond_compiled /opt/venv /opt/venv
410

    
411

    
412
#--- base -> python -> trytond -> WEBAPI --------------------------------------
413

    
414
FROM ${DEBIAN}_trytond AS webapi
415
COPY --from=jessie_pyramid_compiled /opt/venv /opt/venv
416

    
417

    
418
#--- base -> python -> trytond -> WEBGUI --------------------------------------
419

    
420
FROM webapi AS webgui
421

    
422

    
423
#--- base -> python -> DOCUMENTATION ------------------------------------------
424

    
425
FROM ${DEBIAN}_compile AS documentation
426
COPY --from=jessie_trytond_compiled /opt/venv /opt/venv
427
COPY --from=jessie_pyramid_compiled /opt/venv /opt/venv
428
COPY --from=jessie_worker_compiled /opt/venv /opt/venv