Build py2 and py3 images on every commit

This commit is contained in:
Adrian Utrilla 2019-02-11 12:35:57 +01:00
Родитель 00681c1aec
Коммит e12bfb48ec
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 359B37BC29105977
3 изменённых файлов: 71 добавлений и 40 удалений

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

@ -1,48 +1,69 @@
version: 2.0 version: 2.1
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:
- 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 << 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: jobs:
build-deploy: # build for the master branch build-py2:
machine: true machine: true
working_directory: ~/addons-server working_directory: ~/addons-server
steps: steps:
- checkout - checkout
- run: > - build_and_push_container_image:
printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n' image_tag: latest
"$CIRCLE_SHA1" dockerfile: "Dockerfile.python2.deploy"
"$CIRCLE_TAG"
"$CIRCLE_PROJECT_USERNAME" build-py3:
"$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.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)
machine: true machine: true
working_directory: ~/addons-server working_directory: ~/addons-server
steps: steps:
- checkout - checkout
- run: > - build_and_push_container_image:
printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n' image_tag: latest-py3
"$CIRCLE_SHA1" dockerfile: "Dockerfile.python3.deploy"
"$CIRCLE_TAG"
"$CIRCLE_PROJECT_USERNAME" build-py2-tag:
"$CIRCLE_PROJECT_REPONAME" machine: true
"$CIRCLE_BUILD_URL" working_directory: ~/addons-server
> version.json steps:
- run: - checkout
name: Build docker image and push to repo - build_and_push_container_image:
command: | image_tag: "${CIRCLE_TAG}"
docker version dockerfile: "Dockerfile.python2.deploy"
docker build -t app:build -f Dockerfile.py2.deploy .
docker tag app:build ${DOCKERHUB_REPO}:${CIRCLE_TAG} build-py3-tag:
docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASS machine: true
docker push ${DOCKERHUB_REPO}:${CIRCLE_TAG} working_directory: ~/addons-server
steps:
- checkout
- build_and_push_container_image:
image_tag: "${CIRCLE_TAG}-py3"
dockerfile: "Dockerfile.python3.deploy"
integration_test: integration_test:
working_directory: ~/addons-server working_directory: ~/addons-server
machine: true machine: true
@ -147,11 +168,21 @@ workflows:
version: 2 version: 2
build_test_deploy_release: build_test_deploy_release:
jobs: jobs:
- build-deploy: - build-py2:
filters: filters:
branches: branches:
only: master only: master
- build-release: - build-py3:
filters:
branches:
only: master
- build-py2-tag:
filters:
tags:
only: /.*/
branches:
ignore: /.*/
- build-py3-tag:
filters: filters:
tags: tags:
only: /.*/ only: /.*/

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

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

@ -75,9 +75,9 @@ COPY . /data/olympia
WORKDIR /data/olympia WORKDIR /data/olympia
# Install all python requires # Install all python requires
RUN pip install --no-cache-dir --exists-action=w --no-deps -r requirements/system.txt \ RUN pip3 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 \ && pip3 install --no-cache-dir --exists-action=w --no-deps -r requirements/prod_py3.txt \
&& pip install --no-cache-dir --exists-action=w --no-deps -e . && 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 # Link /usr/sbin/uwsgi and /usr/bin/uwsgi to deal with migration from Centos -> Debian
RUN ln -s /usr/bin/uwsgi /usr/sbin/uwsgi RUN ln -s /usr/bin/uwsgi /usr/sbin/uwsgi