stages: - test - build - release variables: CONTAINER_IMAGE: "registry.ely.by/elyby/accounts" test:backend: image: docker:latest services: - mariadb:10.2.11 - redis:3.0-alpine variables: # mariadb config MYSQL_RANDOM_ROOT_PASSWORD: "true" MYSQL_DATABASE: "ely_accounts_test" MYSQL_USER: "ely_accounts_tester" MYSQL_PASSWORD: "ely_accounts_tester_password" stage: test before_script: - docker login -u gitlab-ci -p $CI_BUILD_TOKEN registry.ely.by - echo "$SSH_PRIVATE_KEY" > id_rsa script: - export TEMP_DEV_IMAGE="${CONTAINER_IMAGE}:ci-${CI_BUILD_ID}" - docker build --pull -f Dockerfile-dev -t $TEMP_DEV_IMAGE . - > docker run --rm --add-host=mariadb:`getent hosts mariadb | awk '{ print $1 ; exit }'` --add-host=redis:`getent hosts redis | awk '{ print $1 ; exit }'` -e YII_DEBUG="true" -e YII_ENV="test" -e DB_HOST="mariadb" -e DB_DATABASE="ely_accounts_test" -e DB_USER="ely_accounts_tester" -e DB_PASSWORD="ely_accounts_tester_password" -e REDIS_HOST="redis" $TEMP_DEV_IMAGE php vendor/bin/codecept run -c tests test:frontend: image: node:9.2.1-alpine stage: test cache: paths: - frontend/node_modules before_script: # Enable SSL support for wget - apk add --update openssl # https://github.com/facebook/flow/issues/3649#issuecomment-308070179 - wget -O /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub - wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-2.25-r0.apk - apk add glibc-2.25-r0.apk script: - cd frontend - yarn run build:install - yarn run lint - yarn flow - yarn test build:production: image: docker:latest stage: build before_script: - docker login -u gitlab-ci -p $CI_BUILD_TOKEN registry.ely.by - echo "$SSH_PRIVATE_KEY" > id_rsa - echo "$FRONTEND_ENV_CONFIG" > frontend/config/env.js script: - export IMAGE_NAME="$CONTAINER_IMAGE:latest" - docker build --pull -t $IMAGE_NAME . only: - develop - tags release:latest: image: docker:latest stage: release variables: GIT_STRATEGY: none before_script: - docker login -u gitlab-ci -p $CI_BUILD_TOKEN registry.ely.by script: - docker push $CONTAINER_IMAGE:latest only: - develop - tags release:tag: image: docker:latest stage: release variables: GIT_STRATEGY: none before_script: - docker login -u gitlab-ci -p $CI_BUILD_TOKEN registry.ely.by script: - export IMAGE_NAME="$CONTAINER_IMAGE:$CI_BUILD_TAG" - docker tag $CONTAINER_IMAGE:latest $IMAGE_NAME - docker push $IMAGE_NAME only: - tags