Skip to content

Commit

Permalink
Build py2 and py3 images on every commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Utrilla committed Feb 12, 2019
1 parent 00681c1 commit e12bfb4
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 32 deletions.
89 changes: 60 additions & 29 deletions circle.yml → .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -18,31 +23,47 @@ jobs:
name: Build docker image and push to repo
command: |
docker version
docker build -t app:build -f Dockerfile.py3.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.py2.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
Expand Down Expand Up @@ -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: /.*/
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions Dockerfile.py3.deploy → Dockerfile.python3.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ 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 .
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
Expand Down

0 comments on commit e12bfb4

Please sign in to comment.