Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch local dev and addons-dev to python3 #10640

Merged
merged 3 commits into from Feb 12, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -1,11 +1,16 @@
version: 2.0
version: 2.1

jobs:
build-deploy: # build for the master branch
machine: true
working_directory: ~/addons-server
commands:
build_and_push_container_image:
description: "Builds and pushes a Docker image"
parameters:
dockerfile:
type: string
default: "Dockerfile.python2.deploy"
image_tag:
type: string
default: "latest"
steps:
- checkout
- run: >
printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n'
"$CIRCLE_SHA1"
@@ -18,31 +23,47 @@ jobs:
name: Build docker image and push to repo
command: |
docker version
docker build -t app:build -f Dockerfile.deploy .
docker tag app:build ${DOCKERHUB_REPO}:latest
docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASS
docker push ${DOCKERHUB_REPO}:latest
build-release: # build for releases (tags)
docker build -t app:build -f << parameters.dockerfile >> .
docker tag app:build "${DOCKERHUB_REPO}":<< parameters.image_tag >>
docker login -u "${DOCKERHUB_USER}" -p "${DOCKERHUB_PASS}"
docker push "${DOCKERHUB_REPO}":<< parameters.image_tag >>
jobs:
build-py2:
machine: true
working_directory: ~/addons-server
steps:
- checkout
- run: >
printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n'
"$CIRCLE_SHA1"
"$CIRCLE_TAG"
"$CIRCLE_PROJECT_USERNAME"
"$CIRCLE_PROJECT_REPONAME"
"$CIRCLE_BUILD_URL"
> version.json
- run:
name: Build docker image and push to repo
command: |
docker version
docker build -t app:build -f Dockerfile.deploy .
docker tag app:build ${DOCKERHUB_REPO}:${CIRCLE_TAG}
docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASS
docker push ${DOCKERHUB_REPO}:${CIRCLE_TAG}
- build_and_push_container_image:
image_tag: latest
dockerfile: "Dockerfile.python2.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:
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"

integration_test:
working_directory: ~/addons-server
machine: true
@@ -147,11 +168,21 @@ workflows:
version: 2
build_test_deploy_release:
jobs:
- build-deploy:
- build-py2:
filters:
branches:
only: master
- build-release:
- build-py3:
filters:
branches:
only: master
- build-py2-tag:
filters:
tags:
only: /.*/
branches:
ignore: /.*/
- build-py3-tag:
filters:
tags:
only: /.*/
File renamed without changes.
@@ -0,0 +1,104 @@
FROM python:3.6-slim-stretch

ENV PYTHON_VERSION_MAJOR 3

# 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 \
nodejs \
uuid-dev \
uwsgi \
uwsgi-plugin-python \
# 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 \
&& rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get -t stretch-backports install -y \
# For git-based files storage backend
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

# 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

# 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_py3.txt \
&& pip3 install --no-cache-dir --exists-action=w --no-deps -e .

# 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/

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
@@ -20,7 +20,7 @@ x-env-mapping: &env
services:
worker: &worker
<<: *env
image: addons/addons-server
image: addons/addons-server:latest-py3
command: supervisord -n -c /code/docker/supervisor-celery.conf
entrypoint: ./scripts/start-docker.sh
volumes:
@@ -32,16 +32,6 @@ services:
<<: *worker
command: supervisord -n -c /code/docker/supervisor.conf

web3:
extends:
service: web
image: addons/addons-server:latest-py3
# This container is only for running unit tests under python3 atm, so give
# it a dummy command so that it doesn't exit, but don't let it run
# supervisord as normal - we don't want the webserver.
command: /usr/bin/tail -f /dev/null


nginx:
image: addons/addons-nginx
volumes:
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.