This commit is contained in:
Mathieu Pillard 2019-03-22 12:25:33 +01:00
Родитель 12ef19a886
Коммит 19e782a96d
6 изменённых файлов: 13 добавлений и 246 удалений

Просмотреть файл

@ -6,7 +6,7 @@ commands:
parameters:
dockerfile:
type: string
default: "Dockerfile.python2.deploy"
default: "Dockerfile.deploy"
image_tag:
type: string
default: "latest"
@ -28,41 +28,23 @@ commands:
docker login -u "${DOCKERHUB_USER}" -p "${DOCKERHUB_PASS}"
docker push "${DOCKERHUB_REPO}":<< parameters.image_tag >>
jobs:
build-py2:
build:
machine: true
working_directory: ~/addons-server
steps:
- checkout
- build_and_push_container_image:
image_tag: latest
dockerfile: "Dockerfile.python2.deploy"
dockerfile: "Dockerfile.deploy"
build-py3:
machine: true
working_directory: ~/addons-server
steps:
- checkout
- build_and_push_container_image:
image_tag: latest-py3
dockerfile: "Dockerfile.python3.deploy"
build-py2-tag:
build-tag:
machine: true
working_directory: ~/addons-server
steps:
- checkout
- build_and_push_container_image:
image_tag: "${CIRCLE_TAG}"
dockerfile: "Dockerfile.python2.deploy"
build-py3-tag:
machine: true
working_directory: ~/addons-server
steps:
- checkout
- build_and_push_container_image:
image_tag: "${CIRCLE_TAG}-py3"
dockerfile: "Dockerfile.python3.deploy"
dockerfile: "Dockerfile.deploy"
integration_test:
working_directory: ~/addons-server
@ -95,7 +77,7 @@ jobs:
- restore_cache:
keys:
- uitest-cache-{{ checksum "requirements/docs.txt" }}
- uitest-cache-{{ checksum "requirements/prod_py2.txt" }}
- uitest-cache-{{ checksum "requirements/prod_py3.txt" }}
- uitest-cache-{{ checksum "requirements/tests.txt" }}
- uitest-cache-{{ checksum "requirements/dev.txt" }}
- uitest-cache-{{ checksum "requirements/dev_without_hash.txt" }}
@ -156,7 +138,7 @@ jobs:
paths:
- .tox
- save_cache:
key: uitest-cache-{{ checksum "requirements/prod_py2.txt" }}
key: uitest-cache-{{ checksum "requirements/prod_py3.txt" }}
paths:
- .tox
- save_cache:
@ -184,21 +166,11 @@ workflows:
version: 2
build_test_deploy_release:
jobs:
- build-py2:
- build:
filters:
branches:
only: master
- build-py3:
filters:
branches:
only: master
- build-py2-tag:
filters:
tags:
only: /.*/
branches:
ignore: /.*/
- build-py3-tag:
- build-tag:
filters:
tags:
only: /.*/

Просмотреть файл

@ -1,7 +1,9 @@
FROM python:2.7.15-slim-stretch
FROM python:3.6-slim-stretch
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHON_VERSION_MAJOR 3
# Allow scripts to detect we're running in our own container
RUN touch /addons-server-docker-container
@ -29,10 +31,6 @@ RUN apt-get update && apt-get install -y \
libffi-dev \
libssl-dev \
libmagic-dev \
python-dev \
python3-dev \
python-pip \
python3-pip \
nodejs \
# Git, because we're using git-checkout dependencies
git \

Просмотреть файл

Просмотреть файл

@ -1,106 +0,0 @@
FROM python:2.7.14-slim-stretch
# 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-stretch-nodesource-repo /etc/apt/sources.list.d/nodesource.list
ADD docker/debian-stretch-backports-repo /etc/apt/sources.list.d/backports.list
RUN apt-get update && apt-get 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 \
libmagic-dev \
python-dev \
python-pip \
nodejs \
uuid-dev \
# Git, because we're using git-checkout dependencies
git \
# Dependencies for mysql-python
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/*
# 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 pip install --no-cache-dir --exists-action=w --no-deps -r requirements/system.txt \
&& pip install --no-cache-dir --exists-action=w --no-deps -r requirements/prod_py2.txt \
&& pip 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
# Fix for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=783738
RUN ln -s /usr/lib/python2.7/plat-*/_sysconfigdata_nd.py /usr/lib/python2.7/
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

Просмотреть файл

@ -1,97 +0,0 @@
FROM python:3.6-slim-stretch
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHON_VERSION_MAJOR 3
# Allow scripts to detect we're running in our own container
RUN touch /addons-server-docker-container
# 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-stretch-nodesource-repo /etc/apt/sources.list.d/nodesource.list
ADD docker/debian-stretch-backports-repo /etc/apt/sources.list.d/backports.list
RUN apt-get update && apt-get install -y \
# General (dev-) dependencies
bash-completion \
build-essential \
curl \
libjpeg-dev \
libsasl2-dev \
libxml2-dev \
libxslt-dev \
locales \
zlib1g-dev \
libffi-dev \
libssl-dev \
libmagic-dev \
nodejs \
# Git, because we're using git-checkout dependencies
git \
# Dependencies for mysql-python
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 \
# our makefile and ui-tests require uuid to be installed
uuid \
# Use libmaxmind for speedy geoip lookups
libmaxminddb0 \
libmaxminddb-dev \
&& rm -rf /var/lib/apt/lists/*
ADD http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz /tmp
RUN mkdir -p /usr/local/share/GeoIP \
&& gunzip -c /tmp/GeoLite2-Country.mmdb.gz > /usr/local/share/GeoIP/GeoLite2-Country.mmdb \
&& rm -f /tmp/GeoLite2-Country.mmdb.gz
# Compile required locale
RUN localedef -i en_US -f UTF-8 en_US.UTF-8
# Set the locale. This is mainly so that tests can write non-ascii files to
# disk.
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
COPY . /code
WORKDIR /code
ENV PIP_BUILD=/deps/build/
ENV PIP_CACHE_DIR=/deps/cache/
ENV PIP_SRC=/deps/src/
ENV NPM_CONFIG_PREFIX=/deps/
ENV SWIG_FEATURES="-D__x86_64__"
# Install all python requires
RUN mkdir -p /deps/{build,cache,src}/ && \
ln -s /code/package.json /deps/package.json && \
make update_deps && \
rm -rf /deps/build/ /deps/cache/
# Preserve bash history across image updates.
# This works best when you link your local source code
# as a volume.
ENV HISTFILE /code/docker/artifacts/bash_history
# Configure bash history.
ENV HISTSIZE 50000
ENV HISTIGNORE ls:exit:"cd .."
# This prevents dupes but only in memory for the current session.
ENV HISTCONTROL erasedups
ENV CLEANCSS_BIN /deps/node_modules/.bin/cleancss
ENV LESS_BIN /deps/node_modules/.bin/lessc
ENV UGLIFY_BIN /deps/node_modules/.bin/uglifyjs
ENV ADDONS_LINTER_BIN /deps/node_modules/.bin/addons-linter

Просмотреть файл

@ -22,7 +22,7 @@ x-env-mapping: &env
services:
worker: &worker
<<: *env
image: addons/addons-server:latest-py3
image: addons/addons-server:latest
command: supervisord -n -c /code/docker/supervisor-celery.conf
entrypoint: ./scripts/start-docker.sh
volumes: