Commit 12fd23d9 authored by Aleksander Piotrowski's avatar Aleksander Piotrowski
Browse files

add staging gitlab-ci

parent dc71ed15
......@@ -2,7 +2,8 @@ stages:
- test
- build
- deploy
- release
- release-prepare
- release-deploy
variables:
WEB_IMAGE_NAME: ${CI_REGISTRY_IMAGE}/web
......@@ -31,7 +32,7 @@ variables:
GEOPINE_IMAGE_FRONTEND: "registry.recoded.co/geoplan/geoankieta/geopine:frontend"
GEO_VOLUME: 'geoankieta_${CI_COMMIT_REF_SLUG}'
ENABLE_HTTPS: "True"
SHOULD_ENABLE_HTTPS: "True"
DB_URL: "${DATABASE}${CI_COMMIT_REF_SLUG}"
DEBUG: "on"
SECRET_KEY: "%zhtwec#e&1x=@*vgl&@)tj1x(8kf4)w3g#c)tj#vk*x&f^z@0"
......@@ -165,13 +166,11 @@ build_admin:
- master
except:
- schedules
variables:
HASH: $REACT_APP_HASH
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.recoded.co
script:
- docker pull $GEOPINE_IMAGE_FRONTEND
- docker build --build-arg REACT_APP_HASH=$HASH -t $PANEL_FORMS_IMAGE_NAME:${CI_COMMIT_REF_SLUG} -f admin/Dockerfile.release admin/
- docker build --build-arg REACT_APP_HASH=$(date +'%s') -t $PANEL_FORMS_IMAGE_NAME:${CI_COMMIT_REF_SLUG} -f admin/Dockerfile.release admin/
- docker push $PANEL_FORMS_IMAGE_NAME:${CI_COMMIT_REF_SLUG}
build_panel_discuss:
......@@ -184,13 +183,11 @@ build_panel_discuss:
- master
except:
- schedules
variables:
HASH: $REACT_APP_HASH
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.recoded.co
script:
- docker pull $GEOPINE_IMAGE_FRONTEND
- docker build --build-arg REACT_APP_HASH=$HASH -t $PANEL_DISCUSS_IMAGE_NAME:${CI_COMMIT_REF_SLUG} -f panel_discuss/Dockerfile.release panel_discuss/
- docker build --build-arg REACT_APP_HASH=$(date +'%s') -t $PANEL_DISCUSS_IMAGE_NAME:${CI_COMMIT_REF_SLUG} -f panel_discuss/Dockerfile.release panel_discuss/
- docker push $PANEL_DISCUSS_IMAGE_NAME:${CI_COMMIT_REF_SLUG}
deploy_web:
......@@ -211,7 +208,20 @@ deploy_web:
- docker pull $WEB_IMAGE_NAME:${CI_COMMIT_REF_SLUG}
- docker stop $WEB_CONTAINER_NAME || true
- docker rm $WEB_CONTAINER_NAME || true
- docker run --name $WEB_CONTAINER_NAME -d -v $GEO_VOLUME:/srv/app/media/ -e MINIFY=$MINIFY -e VIRTUAL_HOST=$WEB_VIRTUAL_HOST -e LETSENCRYPT_HOST=$WEB_VIRTUAL_HOST -e DEBUG=$DEBUG -e ENABLE_HTTPS=$ENABLE_HTTPS -e SECRET_KEY=$SECRET_KEY -e DATABASE_URL=$DB_URL -e GOOGLE_API_KEY=$GOOGLE_API_KEY -e EMAIL_URL=$EMAIL_URL --link postgis:db $WEB_IMAGE_NAME:${CI_COMMIT_REF_SLUG}
- docker run --name $WEB_CONTAINER_NAME
-d -v $GEO_VOLUME:/srv/app/media/
-e MINIFY=$MINIFY
-e VIRTUAL_HOST=$WEB_VIRTUAL_HOST
-e LETSENCRYPT_HOST=$WEB_VIRTUAL_HOST
-e DEBUG=$DEBUG
-e ENABLE_HTTPS=$SHOULD_ENABLE_HTTPS
-e FACEBOOK_APP_ID=$FACEBOOK_APP_ID
-e FACEBOOK_API_SECRET=$FACEBOOK_API_SECRET
-e SECRET_KEY=$SECRET_KEY
-e DATABASE_URL=$DB_URL
-e GOOGLE_API_KEY=$GOOGLE_API_KEY
-e EMAIL_URL=$EMAIL_URL
--link postgis:db $WEB_IMAGE_NAME:${CI_COMMIT_REF_SLUG}
after_script:
- docker exec $WEB_CONTAINER_NAME python manage.py migrate
- docker exec $WEB_CONTAINER_NAME python manage.py add_local_host_site
......@@ -235,7 +245,12 @@ deploy_geoforms:
- docker pull $GEOFORMS_IMAGE_NAME:${CI_COMMIT_REF_SLUG}
- docker stop $GEOFORMS_CONTAINER_NAME || true
- docker rm $GEOFORMS_CONTAINER_NAME || true
- docker run --name $GEOFORMS_CONTAINER_NAME -d -e VIRTUAL_HOST=$GEOFORMS_VIRTUAL_HOST -e LETSENCRYPT_HOST=$GEOFORMS_VIRTUAL_HOST -e REACT_APP_ENV=$ENV -e REACT_APP_API_URL=$API_URL -e REACT_APP_MEDIA_URL=$MEDIA_URL -e REACT_APP_GOOGLE_ANALYTICS_ID=$GOOGLE_ANALYTICS_ID $GEOFORMS_IMAGE_NAME:${CI_COMMIT_REF_SLUG}
- docker run --name $GEOFORMS_CONTAINER_NAME -d
-e VIRTUAL_HOST=$GEOFORMS_VIRTUAL_HOST
-e LETSENCRYPT_HOST=$GEOFORMS_VIRTUAL_HOST
-e REACT_APP_ENV=$ENV
-e REACT_APP_API_URL=$API_URL
-e REACT_APP_MEDIA_URL=$MEDIA_URL $GEOFORMS_IMAGE_NAME:${CI_COMMIT_REF_SLUG}
deploy_admin:
stage: deploy
......@@ -254,7 +269,14 @@ deploy_admin:
- docker pull $PANEL_FORMS_IMAGE_NAME:${CI_COMMIT_REF_SLUG}
- docker stop $PANEL_FORMS_CONTAINER_NAME || true
- docker rm $PANEL_FORMS_CONTAINER_NAME || true
- docker run --name $PANEL_FORMS_CONTAINER_NAME -d -e VIRTUAL_HOST=$PANEL_FORMS_VIRTUAL_HOST -e LETSENCRYPT_HOST=$PANEL_FORMS_VIRTUAL_HOST -e REACT_APP_GEOFORMS_URL=$GEOFORMS_URL -e REACT_APP_LOGIN_URL=$LOGIN_URL -e REACT_APP_ENV=$ENV -e REACT_APP_API_URL=$API_URL -e REACT_APP_MEDIA_URL=$MEDIA_URL $PANEL_FORMS_IMAGE_NAME:${CI_COMMIT_REF_SLUG}
- docker run --name $PANEL_FORMS_CONTAINER_NAME -d
-e VIRTUAL_HOST=$PANEL_FORMS_VIRTUAL_HOST
-e LETSENCRYPT_HOST=$PANEL_FORMS_VIRTUAL_HOST
-e REACT_APP_GEOFORMS_URL=$GEOFORMS_URL
-e REACT_APP_LOGIN_URL=$LOGIN_URL
-e REACT_APP_ENV=$ENV
-e REACT_APP_API_URL=$API_URL
-e REACT_APP_MEDIA_URL=$MEDIA_URL $PANEL_FORMS_IMAGE_NAME:${CI_COMMIT_REF_SLUG}
deploy_panel_discuss:
stage: deploy
......@@ -273,10 +295,17 @@ deploy_panel_discuss:
- docker pull $PANEL_DISCUSS_IMAGE_NAME:${CI_COMMIT_REF_SLUG}
- docker stop $PANEL_DISCUSS_CONTAINER_NAME || true
- docker rm $PANEL_DISCUSS_CONTAINER_NAME || true
- docker run --name $PANEL_DISCUSS_CONTAINER_NAME -d -e VIRTUAL_HOST=$PANEL_DISCUSS_VIRTUAL_HOST -e LETSENCRYPT_HOST=$PANEL_DISCUSS_VIRTUAL_HOST -e REACT_APP_DISCUSS_URL=$DISCUSS_URL -e REACT_APP_LOGIN_URL=$LOGIN_URL -e REACT_APP_ENV=$ENV -e REACT_APP_API_URL=$API_URL -e REACT_APP_MEDIA_URL=$MEDIA_URL $PANEL_DISCUSS_IMAGE_NAME:${CI_COMMIT_REF_SLUG}
- docker run --name $PANEL_DISCUSS_CONTAINER_NAME -d
-e VIRTUAL_HOST=$PANEL_DISCUSS_VIRTUAL_HOST
-e LETSENCRYPT_HOST=$PANEL_DISCUSS_VIRTUAL_HOST
-e REACT_APP_DISCUSS_URL=$DISCUSS_URL
-e REACT_APP_LOGIN_URL=$LOGIN_URL
-e REACT_APP_ENV=$ENV
-e REACT_APP_API_URL=$API_URL
-e REACT_APP_MEDIA_URL=$MEDIA_URL $PANEL_DISCUSS_IMAGE_NAME:${CI_COMMIT_REF_SLUG}
release:
stage: release
release_prepare:
stage: release-prepare
only:
- tags
tags:
......@@ -301,6 +330,132 @@ release:
- docker tag $PANEL_DISCUSS_IMAGE_NAME:staging $PANEL_DISCUSS_IMAGE_NAME:${CI_COMMIT_TAG}
- docker push $PANEL_DISCUSS_IMAGE_NAME:${CI_COMMIT_TAG}
release_deploy_web:
stage: release-deploy
only:
- tags
tags:
- deploy
except:
- schedules
variables:
WEB_CONTAINER_NAME: api.${CI_COMMIT_TAG}.master.thebitbybit.com
WEB_VIRTUAL_HOST: api.${CI_COMMIT_TAG}.master.thebitbybit.com
DB_URL: "${DATABASE}${CI_COMMIT_TAG}"
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.recoded.co
- docker volume create $GEO_VOLUME
script:
- docker pull $WEB_IMAGE_NAME:${CI_COMMIT_TAG}
- docker stop $WEB_CONTAINER_NAME || true
- docker rm $WEB_CONTAINER_NAME || true
- docker run --name $WEB_CONTAINER_NAME
-d -v $GEO_VOLUME:/srv/app/media/
-e MINIFY=$MINIFY
-e VIRTUAL_HOST=$WEB_VIRTUAL_HOST
-e LETSENCRYPT_HOST=$WEB_VIRTUAL_HOST
-e DEBUG=$DEBUG
-e ENABLE_HTTPS=$SHOULD_ENABLE_HTTPS
-e FACEBOOK_APP_ID=$FACEBOOK_APP_ID
-e FACEBOOK_API_SECRET=$FACEBOOK_API_SECRET
-e SECRET_KEY=$SECRET_KEY
-e DATABASE_URL=$DB_URL
-e GOOGLE_API_KEY=$GOOGLE_API_KEY
-e EMAIL_URL=$EMAIL_URL
--link postgis:db $WEB_IMAGE_NAME:${CI_COMMIT_TAG}
after_script:
- docker exec $WEB_CONTAINER_NAME python manage.py migrate
- docker exec $WEB_CONTAINER_NAME python manage.py add_local_host_site
- docker exec $WEB_CONTAINER_NAME python manage.py createcachetable
- docker exec $WEB_CONTAINER_NAME python manage.py rebuild_index --noinput
release_deploy_geoforms:
stage: release-deploy
only:
- tags
tags:
- deploy
except:
- schedules
variables:
GEOFORMS_CONTAINER_NAME: geoforms.${CI_COMMIT_TAG}.master.thebitbybit.com
GEOFORMS_VIRTUAL_HOST: geoforms.${CI_COMMIT_TAG}.master.thebitbybit.com
API_URL: "https://api.${CI_COMMIT_TAG}.master.thebitbybit.com/"
MEDIA_URL: "https://api.${CI_COMMIT_TAG}.master.thebitbybit.com"
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.recoded.co
script:
- docker pull $GEOFORMS_IMAGE_NAME:${CI_COMMIT_TAG}
- docker stop $GEOFORMS_CONTAINER_NAME || true
- docker rm $GEOFORMS_CONTAINER_NAME || true
- docker run --name $GEOFORMS_CONTAINER_NAME -d
-e VIRTUAL_HOST=$GEOFORMS_VIRTUAL_HOST
-e LETSENCRYPT_HOST=$GEOFORMS_VIRTUAL_HOST
-e REACT_APP_ENV=$ENV
-e REACT_APP_API_URL=$API_URL
-e REACT_APP_MEDIA_URL=$MEDIA_URL $GEOFORMS_IMAGE_NAME:${CI_COMMIT_TAG}
release_deploy_admin:
stage: release-deploy
only:
- tags
tags:
- deploy
except:
- schedules
variables:
PANEL_FORMS_CONTAINER_NAME: panel.forms.${CI_COMMIT_TAG}.master.thebitbybit.com
PANEL_FORMS_VIRTUAL_HOST: panel.forms.${CI_COMMIT_TAG}.master.thebitbybit.com
API_URL: "https://api.${CI_COMMIT_TAG}.master.thebitbybit.com/"
MEDIA_URL: "https://api.${CI_COMMIT_TAG}.master.thebitbybit.com"
LOGIN_URL: "https://api.${CI_COMMIT_TAG}.master.thebitbybit.com/accounts/"
GEOFORMS_URL: "https://geoforms.${CI_COMMIT_TAG}.master.thebitbybit.com/"
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.recoded.co
script:
- docker pull $PANEL_FORMS_IMAGE_NAME:${CI_COMMIT_TAG}
- docker stop $PANEL_FORMS_CONTAINER_NAME || true
- docker rm $PANEL_FORMS_CONTAINER_NAME || true
- docker run --name $PANEL_FORMS_CONTAINER_NAME -d
-e VIRTUAL_HOST=$PANEL_FORMS_VIRTUAL_HOST
-e LETSENCRYPT_HOST=$PANEL_FORMS_VIRTUAL_HOST
-e REACT_APP_GEOFORMS_URL=$GEOFORMS_URL
-e REACT_APP_LOGIN_URL=$LOGIN_URL
-e REACT_APP_ENV=$ENV
-e REACT_APP_API_URL=$API_URL
-e REACT_APP_MEDIA_URL=$MEDIA_URL $PANEL_FORMS_IMAGE_NAME:${CI_COMMIT_TAG}
release_deploy_panel_discuss:
stage: release-deploy
only:
- tags
tags:
- deploy
except:
- schedules
variables:
PANEL_DISCUSS_CONTAINER_NAME: panel.discuss.${CI_COMMIT_TAG}.master.thebitbybit.com
PANEL_DISCUSS_VIRTUAL_HOST: panel.discuss.${CI_COMMIT_TAG}.master.thebitbybit.com
API_URL: "https://api.${CI_COMMIT_TAG}.master.thebitbybit.com/"
MEDIA_URL: "https://api.${CI_COMMIT_TAG}.master.thebitbybit.com"
LOGIN_URL: "https://api.${CI_COMMIT_TAG}.master.thebitbybit.com/accounts/"
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.recoded.co
script:
- docker pull $PANEL_DISCUSS_IMAGE_NAME:${CI_COMMIT_TAG}
- docker stop $PANEL_DISCUSS_CONTAINER_NAME || true
- docker rm $PANEL_DISCUSS_CONTAINER_NAME || true
- docker run --name $PANEL_DISCUSS_CONTAINER_NAME -d
-e VIRTUAL_HOST=$PANEL_DISCUSS_VIRTUAL_HOST
-e LETSENCRYPT_HOST=$PANEL_DISCUSS_VIRTUAL_HOST
-e REACT_APP_DISCUSS_URL=$DISCUSS_URL
-e REACT_APP_LOGIN_URL=$LOGIN_URL
-e REACT_APP_ENV=$ENV
-e REACT_APP_API_URL=$API_URL
-e REACT_APP_MEDIA_URL=$MEDIA_URL $PANEL_DISCUSS_IMAGE_NAME:${CI_COMMIT_TAG}
build_geopine:
stage: build
tags:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment