Meu yml, onde adicionei as variaveis do mysql.
image: docker:19.03.0
stages:
- pre-build
- build
- test
- deploy
build-docker:
services:
- docker:19.03.0-dind
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
GIT_SSL_NO_VERIFY: "1"
before_script:
- docker info
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
stage: pre-build
script:
- docker build -t todo-list-img .
- docker tag todo-list-img azosnosredna/gitlab_todolist_img:latest
- docker push azosnosredna/gitlab_todolist_img:latest
build-project:
image: azosnosredna/gitlab_todolist_img:latest
services:
- docker:19.03.0-dind
- mysql:5.7
variables:
MYSQL_USER: $DB_USER
MYSQL_PASSWORD: $DB_PASSWORD
MYSQL_DATABASE: $DB_DATABASE
MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
DB_NAME: $DB_DATABASE
DB_USER: $DB_USER
DB_PASSWORD: $DB_PASSWORD
DB_HOST: 'mysql'
DB_PORT: '3306'
SECRET_KEY: $DB_SECRET_KEY
stage: build
image: azosnosredna/gitlab_todolist_img:latest
tags:
- executor-tarefas
dependencies:
- build-docker
script:
- python manage.py makemigrations
- python manage.py migrate
test-project:
image: azosnosredna/gitlab_todolist_img:latest
stage: test
services:
- docker:19.03.0-dind
- mysql:5.7
variables:
MYSQL_USER: $DB_USER
MYSQL_PASSWORD: $DB_PASSWORD
MYSQL_DATABASE: $DB_DATABASE
MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
DB_NAME: $DB_DATABASE
DB_USER: $DB_USER
DB_PASSWORD: $DB_PASSWORD
DB_HOST: 'mysql'
DB_PORT: '3306'
SECRET_KEY: $DB_SECRET_KEY
dependencies:
- build-project
tags:
- executor-tarefas
script:
- python -m unittest setUp