Commit 819deae3 authored by David Foucher's avatar David Foucher
Browse files

Add docker files

parent 03a5619c
Pipeline #1919 passed with stage
in 1 minute and 39 seconds
image: python:3.6
#TODO test docker image with https://github.com/aelsabbahy/goss
cache:
paths:
- ~/.cache/pip/
api publish:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
stage: build
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context ${CI_PROJECT_DIR}/docker --dockerfile $CI_PROJECT_DIR/docker/dockerfile_trefle --build-arg TREFLE_VERSION=$CI_COMMIT_TAG --build-arg TREFLE_GIT=${CI_PROJECT_URL} --destination ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
only:
- /^api-v[0-9.]+$/
before_script:
- python setup.py develop
- pip install -r requirements-dev.txt
backoffice publish:
variables:
TREFLE_OLD_VERSION: "api-v0.6.1"
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
stage: build
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context ${CI_PROJECT_DIR}/docker --dockerfile ${CI_PROJECT_DIR}/docker/dockerfile_backoffice --build-arg TREFLE_VERSION=${CI_COMMIT_TAG} --build-arg TREFLE_OLD_VERSION=${TREFLE_OLD_VERSION} --build-arg TREFLE_GIT=${CI_PROJECT_URL} --destination ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
only:
- /^backoffice-v[0-9.]+$/
test:
image: python:3.6
cache:
paths:
- ~/.cache/pip/
before_script:
- python setup.py develop
- pip install -r requirements-dev.txt
stage: test
script:
- py.test -v --cov
- behave -D coverage-format=long
- py.test -v --cov
- behave -D coverage-format=long
only:
- branches
- master
server {
listen 80 default_server;
server_name trefle.pole-emploi.fr trefle.beta.pole-emploi.fr trefle-labonneformation.beta.pole-emploi.fr trefle-labonneformation.pole-emploi.fr;
charset utf-8;
client_max_body_size 25M;
location @gunicorn-master {
proxy_pass http://trefle:8000;
proxy_redirect off;
proxy_set_header Host $host;
}
location = / {
root /srv/trefle/trefle;
rewrite ^/$ /0.7/explorer last;
}
location /0.7 {
root /srv/trefle/trefle;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location /0.7/explorer {
alias /srv/trefle/trefle/explorer;
index index.html;
}
rewrite /0.7/(.*) /$1 break;
try_files $uri @gunicorn-master;
}
location /api-moteur/0.7 {
rewrite /api-moteur/0.7/(.*) /$1 break;
try_files $uri @gunicorn-master;
}
location ^~ {
rewrite ^/(.*)$ /0.7/$1 last;
}
#previous API version
location @gunicorn-old {
proxy_pass http://trefle-old:8000;
proxy_redirect off;
proxy_set_header Host $host;
}
location /0.6 {
root /srv/trefle-old/trefle;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location /0.6/explorer {
alias /srv/trefle-old/trefle/explorer;
index index.html;
}
rewrite /0.6/(.*) /$1 break;
try_files $uri @gunicorn-old;
}
location /api-moteur/0.6 {
rewrite /api-moteur/0.6/(.*) /$1 break;
try_files $uri @gunicorn-old;
}
}
version: "3.3"
services:
trefle:
restart: unless-stopped
build:
context: .
dockerfile: dockerfile_trefle
args:
- TREFLE_VERSION=${VERSION}
- TREFLE_GIT=${TREFLE_GIT:-https://git.beta.pole-emploi.fr/open-source/trefle.git}
volumes:
- ./log/trefle:/srv/log
environment:
- LBF_CHARMAP=${LBF_CHARMAP}
- CATALOG_USER=${CATALOG_USER}
- CATALOG_KEY=${CATALOG_KEY}
- CATALOG_URL=${CATALOG_URL}
#version majeur précédente
trefle-old:
restart: unless-stopped
build:
context: .
dockerfile: dockerfile_trefle
args:
- TREFLE_VERSION=${OLD_VERSION}
- TREFLE_GIT=${TREFLE_GIT:-https://git.beta.pole-emploi.fr/open-source/trefle.git}
volumes:
- ./log/trefle-old:/srv/log
environment:
- LBF_CHARMAP=${LBF_CHARMAP}
- CATALOG_USER=${CATALOG_USER}
- CATALOG_KEY=${CATALOG_KEY}
- CATALOG_URL=${CATALOG_URL}
backoffice:
restart: unless-stopped
build:
context: .
dockerfile: dockerfile_backoffice
args:
- TREFLE_GIT=${TREFLE_GIT:-https://git.beta.pole-emploi.fr/open-source/trefle.git}
- TREFLE_VERSION=${VERSION}
- TREFLE_OLD_VERSION=${OLD_VERSION}
depends_on:
- trefle
- trefle-old
volumes:
- ./backoffice/etc/nginx/sites-enabled:/etc/nginx/sites-enabled
- ./log/nginx:/var/log/nginx
dns:
- 1.1.1.1
ports:
- ${PORT:-80}:80
environment:
- VERSION=${VERSION}
- HOST=trefle
- OLD_VERSION=${OLD_VERSION}
- OLD_HOST=trefle-old
FROM ubuntu:xenial
LABEL maintainer="labonneformation@pole-emploi.fr"
ENV LANG C.UTF-8
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get -y install \
apt-utils\
software-properties-common\
unzip \
nginx \
vim \
bzip2 \
cron \
logrotate \
iptables \
git \
dnsutils
ARG TREFLE_GIT
ARG TREFLE_VERSION
RUN git clone -b ${TREFLE_VERSION} ${TREFLE_GIT} /srv/trefle && \
chown -R www-data: /srv/trefle && \
chmod -R u+rwx /srv/trefle
ARG TREFLE_OLD_VERSION
RUN git clone -b ${TREFLE_OLD_VERSION} ${TREFLE_GIT} /srv/trefle-old && \
chown -R www-data: /srv/trefle-old && \
chmod -R u+rwx /srv/trefle-old
CMD service nginx start; \
cron -f
FROM python:3.6
LABEL MAINTAINER "labonneformation@pole-emploi.fr"
ENV LANG C.UTF-8
ENV PYTHON_VERSION 3.6
ENV TREFLE_LOG_DIR /srv/log
ARG TREFLE_VERSION
ARG TREFLE_GIT
RUN apt-get update && apt-get -y install \
software-properties-common\
unzip \
vim \
bzip2 \
git\
pkg-config\
logrotate\
cron
# setup system
RUN mkdir -p ${TREFLE_LOG_DIR}
WORKDIR /srv
COPY trefle/etc/logrotate.d/gunicorn.logrotate /etc/logrotate.d/gunicorn
#deploy
COPY trefle/srv/gunicorn.conf.py ./gunicorn.conf.py
# setup virtualenv
RUN pip install pip -U && \
pip install gunicorn && \
pip install git+${TREFLE_GIT}@${TREFLE_VERSION}
#start
COPY trefle/start.sh .
ENTRYPOINT ./start.sh
This diff is collapsed.
[2019-11-25 17:11:59 +0000] [8] [INFO] Starting gunicorn 20.0.2
[2019-11-25 17:11:59 +0000] [8] [INFO] Listening at: http://0.0.0.0:8000 (8)
[2019-11-25 17:11:59 +0000] [8] [INFO] Using worker: roll.worker.Worker
[2019-11-25 17:11:59 +0000] [12] [INFO] Booting worker with pid: 12
[2019-11-25 17:11:59 +0000] [13] [INFO] Booting worker with pid: 13
[2019-11-25 17:11:59 +0000] [14] [INFO] Booting worker with pid: 14
[2019-11-25 17:11:59 +0000] [15] [INFO] Booting worker with pid: 15
[2019-11-25 17:43:14 +0000] [8] [INFO] Starting gunicorn 20.0.2
[2019-11-25 17:43:14 +0000] [8] [INFO] Listening at: http://0.0.0.0:8000 (8)
[2019-11-25 17:43:14 +0000] [8] [INFO] Using worker: roll.worker.Worker
[2019-11-25 17:43:14 +0000] [12] [INFO] Booting worker with pid: 12
[2019-11-25 17:43:14 +0000] [13] [INFO] Booting worker with pid: 13
[2019-11-25 17:43:14 +0000] [14] [INFO] Booting worker with pid: 14
[2019-11-25 17:43:14 +0000] [15] [INFO] Booting worker with pid: 15
[2019-11-25 18:15:37 +0000] [8] [INFO] Starting gunicorn 20.0.2
[2019-11-25 18:15:37 +0000] [8] [INFO] Listening at: http://0.0.0.0:8000 (8)
[2019-11-25 18:15:37 +0000] [8] [INFO] Using worker: roll.worker.Worker
[2019-11-25 18:15:37 +0000] [12] [INFO] Booting worker with pid: 12
[2019-11-25 18:15:37 +0000] [13] [INFO] Booting worker with pid: 13
[2019-11-25 18:15:37 +0000] [14] [INFO] Booting worker with pid: 14
[2019-11-25 18:15:37 +0000] [15] [INFO] Booting worker with pid: 15
[2019-11-25 18:32:20 +0000] [9] [INFO] Starting gunicorn 20.0.2
[2019-11-25 18:32:20 +0000] [9] [INFO] Listening at: http://0.0.0.0:8000 (9)
[2019-11-25 18:32:20 +0000] [9] [INFO] Using worker: roll.worker.Worker
[2019-11-25 18:32:20 +0000] [13] [INFO] Booting worker with pid: 13
[2019-11-25 18:32:20 +0000] [14] [INFO] Booting worker with pid: 14
[2019-11-25 18:32:20 +0000] [15] [INFO] Booting worker with pid: 15
[2019-11-25 18:32:20 +0000] [16] [INFO] Booting worker with pid: 16
[2019-12-02 17:06:03 +0000] [8] [INFO] Starting gunicorn 20.0.4
[2019-12-02 17:06:03 +0000] [8] [INFO] Listening at: http://0.0.0.0:8000 (8)
[2019-12-02 17:06:03 +0000] [8] [INFO] Using worker: roll.worker.Worker
[2019-12-02 17:06:03 +0000] [11] [INFO] Booting worker with pid: 11