Last active
April 20, 2019 16:55
-
-
Save clintonb/45d059805747c1a5f432df75ffd09467 to your computer and use it in GitHub Desktop.
Gitlab CI deploy configuration for https://github.com/clintonb/cookiecutter-django
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: docker:latest | |
services: | |
- docker:dind | |
variables: | |
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG | |
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest | |
before_script: | |
- apk add --no-cache build-base git libffi-dev make openssl-dev py-pip python python-dev | |
- pip install docker-compose | |
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com | |
- docker version | |
- docker-compose version | |
stages: | |
- build | |
- test | |
- pre-deploy | |
validate_terraform: | |
stage: build | |
script: | |
- sh .ci/install_terraform.sh | |
- make validate_terraform | |
build: | |
stage: build | |
script: | |
- make docker.build | |
- docker tag $CONTAINER_RELEASE_IMAGE $CONTAINER_TEST_IMAGE | |
- docker push $CONTAINER_TEST_IMAGE | |
test: | |
stage: test | |
coverage: '/TOTAL.+ ([0-9]{1,3}%)/' | |
script: | |
- docker pull $CONTAINER_TEST_IMAGE | |
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE | |
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run app "make quality" | |
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run app "./wait-for-it.sh db:5432 -- make detect_missing_migrations" | |
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run app "./wait-for-it.sh db:5432 -- make migrate" | |
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run app "./wait-for-it.sh db:5432 -- make static" | |
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run app "./wait-for-it.sh db:5432 -- make test" | |
push_image: | |
stage: pre-deploy | |
script: | |
- docker pull $CONTAINER_TEST_IMAGE | |
# Tag for Gitlab | |
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE | |
- docker push $CONTAINER_RELEASE_IMAGE | |
only: | |
- master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3" | |
services: | |
db: | |
container_name: db | |
environment: | |
- POSTGRES_USER=postgres | |
- POSTGRES_PASSWORD=postgres | |
- POSTGRES_DB=<YOUR-DB-NAME> | |
image: mdillon/postgis:11-alpine | |
app: | |
# NOTE: A command should be passed to the container via docker-compose run. This ensures we don't start | |
# gunicorn unnecessarily, and run out of memory. | |
entrypoint: | |
- bash | |
- -c | |
environment: | |
- SECRET_KEY=replace-me | |
- DATABASE_URL=postgis://postgres:postgres@db:5432/<YOUR-DB-NAME>?connect_timeout=60 | |
- DEFAULT_FILE_STORAGE=django.core.files.storage.FileSystemStorage | |
links: | |
- db |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment