From 8d75ef6bddce6fda1837ad01232167aaefa3fe7a Mon Sep 17 00:00:00 2001 From: janmax <mail-github@jmx.io> Date: Tue, 24 Oct 2017 01:18:13 +0200 Subject: [PATCH] Adding some CI/CD capabilitys (experimental) --- .gitlab-ci.yml | 18 +++++------------- Dockerfile | 9 +++++---- docker-compose.yml | 2 +- grady/settings/default.py | 10 ++-------- grady/settings/live.py | 2 +- requirements.txt | 1 - 6 files changed, 14 insertions(+), 28 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1ec1ca9b..7a9b1d10 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,16 +7,13 @@ stages: variables: IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME -before_script: - - 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 login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - docker build -t $IMAGE_TAG . - docker push $IMAGE_TAG @@ -24,24 +21,19 @@ test: stage: test image: $IMAGE_TAG services: - postgres:9.5 - variables: - POSTGRES_DB: grady_dev - DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB" + - postgres:9.5 script: - coverage run manage.py test --noinput - coverage report --skip-covered - staging: - state: staging + stage: staging + image: $IMAGE_TAG services: - postgres:9.5 + - 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 index 9441c001..d7368bbc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,14 @@ 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 apk add --no-cache curl RUN npm install yarn -g RUN mkdir /code @@ -19,4 +17,7 @@ ADD . /code/ WORKDIR /code RUN pip install -r requirements.txt -RUN yarn +RUN yarn install --modules-folder core/static/node_modules + +RUN mkdir -p /usr/share/dict +RUN curl https://gitlab.gwdg.de/snippets/51/raw --output /usr/share/dict/words diff --git a/docker-compose.yml b/docker-compose.yml index 2c968bd5..8af15b4d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3' services: postgres: - image: postgres:latest + image: postgres:9.5 web: build: . command: diff --git a/grady/settings/default.py b/grady/settings/default.py index ab3a61db..d96dd4d2 100644 --- a/grady/settings/default.py +++ b/grady/settings/default.py @@ -83,13 +83,9 @@ DATABASES = { 'NAME': 'postgres', 'USER': 'postgres', 'PASSWORD': 'postgres', - 'HOST': 'postgres', + 'HOST': '0.0.0.0', 'PORT': '5432', }, - 'filestorage': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'default_db.sqlite3'), - }, } # Password validation @@ -122,9 +118,7 @@ USE_TZ = True # https://docs.djangoproject.com/en/1.10/howto/static-files/ STATIC_URL = '/static/' -STATICFILES_DIRS = [ - os.path.join(BASE_DIR, "static"), -] +STATIC_ROOT = os.path.join(BASE_DIR, 'static/') FIXTURE_DIRS = ['/core/fixtures/'] diff --git a/grady/settings/live.py b/grady/settings/live.py index 0a113760..fcd378e4 100644 --- a/grady/settings/live.py +++ b/grady/settings/live.py @@ -21,5 +21,5 @@ DATABASES = { 'PASSWORD': 'postgres', 'HOST': 'postgres', 'PORT': '5432', - }, + }, } diff --git a/requirements.txt b/requirements.txt index aef2bcc1..4ae37bb7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,5 +5,4 @@ django_compressor~=2.1.1 gunicorn~=19.7.0 psycopg2~=2.7.1 xlrd~=1.0.0 -lxml~=3.8.0 pytest-cov~=2.5.1 -- GitLab