forked from mozilla/addons-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.deploy
111 lines (95 loc) · 4.5 KB
/
Dockerfile.deploy
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
FROM python:3.6-slim-buster
# need to compile swig
ENV SWIG_FEATURES="-D__x86_64__"
# Should change it to use ARG instead of ENV for OLYMPIA_UID
# once the jenkins server is upgraded to support docker >= v1.9.0
ENV OLYMPIA_UID=9500
RUN useradd -u ${OLYMPIA_UID} -s /sbin/nologin olympia
# Add nodesource repository and requirements
ADD docker/nodesource.gpg.key /etc/pki/gpg/GPG-KEY-nodesource
RUN apt-get update && apt-get install -y \
apt-transport-https \
gnupg2 \
&& rm -rf /var/lib/apt/lists/*
RUN cat /etc/pki/gpg/GPG-KEY-nodesource | apt-key add -
ADD docker/debian-buster-nodesource-repo /etc/apt/sources.list.d/nodesource.list
ADD docker/debian-buster-backports-repo /etc/apt/sources.list.d/buster-backports.list
# IMPORTANT: When editing this list below, make sure to also update
# `Dockerfile`.
RUN apt-get update && apt-get -t buster install -y \
# General (dev-) dependencies
bash-completion \
build-essential \
curl \
libcap-dev \
libjpeg-dev \
libpcre3-dev \
libsasl2-dev \
libxml2-dev \
libxslt-dev \
locales \
zlib1g-dev \
libffi-dev \
libssl-dev \
nodejs \
# Git, because we're using git-checkout dependencies
git \
# Dependencies for mysql-python
default-mysql-client \
default-libmysqlclient-dev \
swig \
gettext \
# Use rsvg-convert to render our static theme previews
librsvg2-bin \
# Use pngcrush to optimize the PNGs uploaded by developers
pngcrush \
# Use libmaxmind for speedy geoip lookups
libmaxminddb0 \
libmaxminddb-dev \
&& rm -rf /var/lib/apt/lists/*
# IMPORTANT: When editing one of these lists below, make sure to also update
# `Dockerfile`.
ADD docker/etc/mime.types /etc/mime.types
# Install a recent libgit2-dev version...
RUN apt-get update && apt-get -t buster-backports install -y \
libgit2-dev \
&& rm -rf /var/lib/apt/lists/*
# Compile required locale
RUN localedef -i en_US -f UTF-8 en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
# version.json is overwritten by CircleCI (see circle.yml).
# The pipeline v2 standard requires the existence of /app/version.json
# inside the docker image, thus it's copied there.
COPY version.json /app/version.json
COPY . /data/olympia
WORKDIR /data/olympia
# Install all python requires
RUN pip3 install --no-cache-dir --exists-action=w --no-deps -r requirements/system.txt \
&& pip3 install --no-cache-dir --exists-action=w --no-deps -r requirements/prod.txt \
&& pip3 install --no-cache-dir --exists-action=w --no-deps -r requirements/prod_without_hash.txt \
&& pip3 install --no-cache-dir --exists-action=w --no-deps -e .
# Link /usr/bin/uwsgi to /usr/local/bin/uwsgi, as that was the
# previous location of the binary when installed by apt-get.
RUN ln -s /usr/local/bin/uwsgi /usr/bin/uwsgi
# Install uwsgi statsd exporter to collect metrics from uwsgi when deployed
WORKDIR /usr/lib/uwsgi/plugins
RUN uwsgi --build-plugin https://github.com/Datadog/uwsgi-dogstatsd && \
rm -rf uwsgi-dogstatsd
# Link /usr/sbin/uwsgi and /usr/bin/uwsgi to deal with migration from Centos -> Debian
RUN ln -s /usr/bin/uwsgi /usr/sbin/uwsgi
WORKDIR /data/olympia
RUN echo "from olympia.lib.settings_base import *\n\
LESS_BIN = 'node_modules/less/bin/lessc'\n\
CLEANCSS_BIN = 'node_modules/clean-css-cli/bin/cleancss'\n\
UGLIFY_BIN = 'node_modules/uglify-js/bin/uglifyjs'\n\
FXA_CONFIG = {'default': {}, 'internal': {}}\n"\
> settings_local.py
RUN DJANGO_SETTINGS_MODULE='settings_local' locale/compile-mo.sh locale
# compile asssets
RUN npm install \
&& make -f Makefile-docker copy_node_js \
&& DJANGO_SETTINGS_MODULE='settings_local' python manage.py compress_assets \
&& DJANGO_SETTINGS_MODULE='settings_local' python manage.py generate_jsi18n_files \
&& DJANGO_SETTINGS_MODULE='settings_local' python manage.py collectstatic --noinput
RUN rm -f settings_local.py settings_local.pyc