From d2193bc4daf1c9a927ad00556313f21af035148b Mon Sep 17 00:00:00 2001 From: janmax <mail-github@jmx.io> Date: Mon, 23 Oct 2017 23:29:54 +0200 Subject: [PATCH] More CI/CD stuff that sure wont work --- .gitlab-ci.yml | 44 +++++++++++++++++++++++++++++++++++--------- Dockerfile | 22 ++++++++++++++++++++++ docker-compose.yml | 20 ++++++++++++++++++++ 3 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f276820..1ec1ca9b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,21 +1,47 @@ -image: python:3.6 - -services: - - postgres:9.5 +stages: + - build + - test + - staging variables: - POSTGRES_DB: grady_dev + IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME before_script: - - apt-get update && apt-get install wamerican - - python -V - - pip install --upgrade pip - - pip install -U -r requirements.txt + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + +build: + image: docker:latest + services: + - docker:dind + stage: build + script: + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN docker.gitlab.gwdg.de + - docker build -t $IMAGE_TAG . + - docker push $IMAGE_TAG test: + stage: test + image: $IMAGE_TAG + services: + postgres:9.5 variables: + POSTGRES_DB: grady_dev DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB" script: - coverage run manage.py test --noinput - coverage report --skip-covered + + +staging: + state: staging + services: + postgres:9.5 + environment: + name: review/$CI_COMMIT_REF_NAME + url: https://staging.grady.janmax.org + image: $IMAGE_TAG + script: + - python3 manage.py migrate --noinput + - python3 manage.py loaddata core/fixtures/testdata-groups.json + - gunicorn --bind 0.0.0.0:8000 grady.wsgi diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..9441c001 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM python:3.6-alpine + +ENV PYTHONUNBUFFERED 1 +ENV DJANGO_DEV 1 + +RUN apk add --no-cache nodejs +RUN apk add --no-cache postgresql-dev +RUN apk add --no-cache gcc +RUN apk add --no-cache python3-dev +RUN apk add --no-cache musl-dev +RUN apk add --no-cache libgcrypt-dev +RUN apk add --no-cache libxslt-dev +RUN apk add --no-cache bash +RUN npm install yarn -g + +RUN mkdir /code +ADD requirements.txt /code/ +ADD . /code/ + +WORKDIR /code +RUN pip install -r requirements.txt +RUN yarn diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..2c968bd5 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: '3' + +services: + postgres: + image: postgres:latest + web: + build: . + command: + - bash + - -c + - | + python3 manage.py migrate --noinput + python3 manage.py loaddata core/fixtures/testdata-groups.json + gunicorn --bind 0.0.0.0:8000 grady.wsgi + volumes: + - .:/code + ports: + - "8000:8000" + depends_on: + - postgres -- GitLab