From 1384f12a12c2845007702c3c5da74f79be4adc58 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Fri, 14 Dec 2018 20:40:29 +0100 Subject: [PATCH] CI is swag --- .gitlab-ci.yml | 40 ++++++++++++++++++++++++++++++++++++++++ Dockerfile | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..62f38ed --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,40 @@ +image: docker +services: +- docker:dind + +before_script: +- apk add --no-cache curl +- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN gitlab.rezometz.org:5678 + +stages: +- build +- deploy + +.build_image: &build_image + stage: build + script: + - docker build -f Dockerfile -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA . + +build_image_test: + <<: *build_image + stage: build + except: + - master + +build_image_prod: + <<: *build_image + stage: build + after_script: + - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest + - docker push $CI_REGISTRY_IMAGE:latest + only: + - master + +deploy: + stage: deploy + script: + - "curl -X POST lupercus.rez -d \"$API_VARS\" -H \"Content-Type: application/json\" --fail" + only: + - master + environment: + name: production diff --git a/Dockerfile b/Dockerfile index 5cc6b19..f775dc5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM python:3 ENV PYTHONUNBUFFERED 1 RUN mkdir /django -ADD . /django/ +ADD ./comet /django/ WORKDIR /django RUN pip install -r requirements.txt CMD sleep 5; python manage.py migrate; python manage.py collectstatic --noinput; gunicorn comet.wsgi -b 0.0.0.0:8000