aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2018-09-17 22:53:10 +0200
committerGravatar Johannes Christ <[email protected]>2018-09-17 23:51:12 +0200
commitf8d00d60156329cba6f66c66cdc73f4a845372a2 (patch)
tree0165f44ee5ec64c8475479084bf7cf7d41efdf2c
parentOnly run `deploy` step on `master` and `django`. (diff)
Build docker image and pass it around.
-rw-r--r--.gitlab-ci.yml63
-rw-r--r--docker/app/alpine/3.6/Dockerfile13
-rw-r--r--docker/app/alpine/3.7/Dockerfile13
-rw-r--r--docker/app/stretch/3.6/Dockerfile18
-rw-r--r--docker/app/stretch/3.7/Dockerfile18
5 files changed, 116 insertions, 9 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 41ec8565..8ec327e3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,5 @@
stages:
+ - build
- lint
- test
- publish
@@ -19,30 +20,74 @@ image: python:3.7-alpine
POSTGRES_PASSWORD: supersecret
POSTGRES_USER: django
+build-alpine-3.7:
+ stage: build
+ image: docker:dind
+ script:
+ - docker build --build-arg EXTRAS=test,lint -t django:alpine-3.7 -f docker/app/alpine/3.7/Dockerfile .
+ - docker save django:alpine-3.7 django_alpine_py37.tar.gz
+ artifacts:
+ paths:
+ - django_alpine_py37.tar.gz
+
+build-alpine-3.6:
+ stage: build
+ image: docker:dind
+ script:
+ - docker build --build-arg EXTRAS=test -t django:alpine-3.6 -f docker/app/alpine/3.6/Dockerfile .
+ - docker save django:alpine-3.6 django_alpine_py36.tar.gz
+ artifacts:
+ paths:
+ - django_alpine_py36.tar.gz
+
+build-stretch-3.7:
+ stage: build
+ image: docker:dind
+ script:
+ - docker build --build-arg EXTRAS=test -t django:stretch-3.7 -f docker/app/stretch/3.7/Dockerfile .
+ - docker save django:stretch-3.7 django_stretch_py37.tar.gz
+ artifacts:
+ paths:
+ - django_stretch_py37.tar.gz
+
+build-stretch-3.6:
+ stage: build
+ image: docker:dind
+ script:
+ - docker build --build-arg EXTRAS=test -t django:stretch-3.6 -f docker/app/stretch/3.6/Dockerfile .
+ - docker save django:stretch-3.6 django_stretch_py36.tar.gz
+ artifacts:
+ paths:
+ - django_stretch_py36.tar.gz
+
lint:
stage: lint
+ image: docker:dind
before_script:
- - apk add python3-dev git libpq postgresql-dev gcc cmake autoconf automake musl-dev
- - python3 -m pip install --no-cache-dir .[lint]
+ - docker load < django_alpine_py37.tar.gz
script:
- - flake8
+ - docker run django:alpine-3.7 flake8
tags:
- docker
+ dependencies:
+ - build-alpine-3.7
+
test-3.7-alpine:
<<: *test-template
- image: python:3.7-alpine
+ image: docker:dind
before_script:
- - apk add python3-dev git libpq postgresql-dev gcc cmake autoconf automake musl-dev
- - python3 -m pip install --no-cache-dir .[test]
- - python manage.py migrate
+ - docker load < django:alpine-3.7
+ - docker run --network=host --env DATABASE_URL=$DATABASE_URL django:alpine-3.7 python manage.py migrate
script:
- - coverage run --source=api,home,pysite,wiki --branch manage.py test
+ - docker container run --network=host --env DATABASE_URL=$DATABASE_URL -v ./:/app django:alpine-3.7 coverage run --source=api,home,pysite,wiki --branch manage.py test
after_script:
- - coverage report
+ - docker contianer run -v ./:/app coverage report
artifacts:
paths:
- .coverage
+ dependencies:
+ - build-alpine-3.7
test-3.6-alpine:
<<: *test-template
diff --git a/docker/app/alpine/3.6/Dockerfile b/docker/app/alpine/3.6/Dockerfile
new file mode 100644
index 00000000..c062ee8e
--- /dev/null
+++ b/docker/app/alpine/3.6/Dockerfile
@@ -0,0 +1,13 @@
+FROM python:3.6-alpine
+
+ARG EXTRAS=deploy
+
+RUN apk add git libpq postgresql-dev gcc cmake autoconf automake musl-dev
+
+COPY . /app
+WORKDIR /app
+
+RUN python3 -m pip install .[$EXTRAS]
+RUN apk del git gcc cmake autoconf automake
+
+CMD ["gunicorn", "--workers", "4", "--bind", "0.0.0.0:4000", "pysite.wsgi:applicati
diff --git a/docker/app/alpine/3.7/Dockerfile b/docker/app/alpine/3.7/Dockerfile
new file mode 100644
index 00000000..4583840b
--- /dev/null
+++ b/docker/app/alpine/3.7/Dockerfile
@@ -0,0 +1,13 @@
+FROM python:3.7-alpine
+
+ARG EXTRAS=deploy
+
+RUN apk add git libpq postgresql-dev gcc cmake autoconf automake musl-dev
+
+COPY . /app
+WORKDIR /app
+
+RUN python3 -m pip install .[$EXTRAS]
+RUN apk del git gcc cmake autoconf automake
+
+CMD ["gunicorn", "--workers", "4", "--bind", "0.0.0.0:4000", "pysite.wsgi:application"]
diff --git a/docker/app/stretch/3.6/Dockerfile b/docker/app/stretch/3.6/Dockerfile
new file mode 100644
index 00000000..4cabdbfa
--- /dev/null
+++ b/docker/app/stretch/3.6/Dockerfile
@@ -0,0 +1,18 @@
+FROM python:3.6-stretch
+
+ARG EXTRAS=deploy
+
+RUN apt-get update -y
+RUN apt-get install -y \
+ autoconf \
+ automake \
+ cmake \
+ gcc \
+ git \
+ libc-dev
+ libpq-dev \
+
+
+RUN python3 -m pip install .[$EXTRAS]
+
+CMD ["gunicorn", "--workers", "4", "--bind", "0.0.0.0:4000", "pysite.wsgi:applicati
diff --git a/docker/app/stretch/3.7/Dockerfile b/docker/app/stretch/3.7/Dockerfile
new file mode 100644
index 00000000..32aee420
--- /dev/null
+++ b/docker/app/stretch/3.7/Dockerfile
@@ -0,0 +1,18 @@
+FROM python:3.7-stretch
+
+ARG EXTRAS=deploy
+
+RUN apt-get update -y
+RUN apt-get install -y \
+ autoconf \
+ automake \
+ cmake \
+ gcc \
+ git \
+ libc-dev
+ libpq-dev \
+
+
+RUN python3 -m pip install .[$EXTRAS]
+
+CMD ["gunicorn", "--workers", "4", "--bind", "0.0.0.0:4000", "pysite.wsgi:applicati