85 строки
3.9 KiB
Docker
85 строки
3.9 KiB
Docker
FROM centos:centos7
|
|
|
|
# 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 docker/nodesource.gpg.key /etc/pki/rpm-gpg/RPM-GPG-KEY-nodesource
|
|
ADD docker/epel.gpg.key /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
|
|
ADD docker/nodesource.repo docker/epel.repo /etc/yum.repos.d/
|
|
|
|
RUN yum install -y \
|
|
gcc-c++ \
|
|
gettext \
|
|
# Git, because we're using git-checkout dependencies
|
|
git \
|
|
libffi-devel \
|
|
libxml2-devel \
|
|
libxslt-devel \
|
|
mariadb \
|
|
mariadb-devel \
|
|
nodejs \
|
|
openssl-devel \
|
|
python-devel \
|
|
swig \
|
|
uwsgi-2.0.13.1-2.el7 \
|
|
uwsgi-plugin-python \
|
|
&& yum clean all \
|
|
&& curl -sSL https://bootstrap.pypa.io/get-pip.py | python
|
|
|
|
# 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
|
|
|
|
# The pipeline v2 standard requires the existence of /app/version.json
|
|
# inside the docker image, although the content of the file comes from
|
|
# circle.yml.
|
|
# We realize that the content of version.json is written twice (once in
|
|
# circle.yml, and the other in the end of this file), we should remove
|
|
# the bits at the end of this file after we fully migrate to use pipeline
|
|
# v2.
|
|
COPY version.json /app/version.json
|
|
COPY . /data/olympia
|
|
WORKDIR /data/olympia
|
|
|
|
# Install all python requires
|
|
RUN pip install --no-cache-dir --exists-action=w --no-deps -r requirements/prod.txt \
|
|
&& [ -f requirements/prod_without_hash.txt ] \
|
|
&& pip install --no-cache-dir --exists-action=w --no-deps -r requirements/prod_without_hash.txt\
|
|
&& pip install --no-cache-dir --exists-action=w --no-deps -e .
|
|
|
|
RUN echo -e "from olympia.lib.settings_base import *\n\
|
|
STYLUS_BIN = 'node_modules/stylus/bin/stylus'\n\
|
|
LESS_BIN = 'node_modules/less/bin/lessc'\n\
|
|
CLEANCSS_BIN = 'node_modules/clean-css/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 \
|
|
&& DJANGO_SETTINGS_MODULE='settings_local' python manage.py compress_assets -t \
|
|
&& DJANGO_SETTINGS_MODULE='settings_local' python manage.py collectstatic --noinput
|
|
|
|
RUN rm -f settings_local.py settings_local.pyc
|
|
|
|
RUN [[ -z "$CIRCLE_TAG" ]] \
|
|
&& { \
|
|
GITREF=$(git rev-parse HEAD) \
|
|
GITTAG=$(git name-rev --tags --name-only $GITREF) \
|
|
SOURCE='https://github.com/mozilla/addons-server' \
|
|
&& echo "{\"source\": \"$SOURCE\", \"version\": \"$GITTAG\", \"commit\": \"$GITREF\"}" > version.json ;\
|
|
} || { \
|
|
GITREF=$(git rev-parse HEAD) \
|
|
GITTAG=$CIRCLE_TAG \
|
|
SOURCE='https://github.com/mozilla/addons-server' \
|
|
&& echo "{\"source\": \"$SOURCE\", \"version\": \"$GITTAG\", \"commit\": \"$GITREF\"}" > version.json ;\
|
|
}
|