image: docker

services:
  - docker:dind

stages:
  - deploy

step-deploy-prod:
  stage: deploy
  only:
    - master
  script:
    - sudo apt-get install -y python-pip
    - sudo pip install docker-compose
    - sudo docker image prune -f
    - replace "5000:5000" "5003:5000" -- docker-compose-test.yml
    - replace "domains=" "$domains" -- docker-compose-test.yml
    - replace "recaptcha_private=" "$recaptcha_private" -- docker-compose-test.yml
    - replace "recaptcha_public=" "$recaptcha_public" -- docker-compose-test.yml
    - sudo docker-compose -f "docker-compose-test.yml" up -d --build
    - sudo docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - sudo docker push $CI_REGISTRY/group/project/image:latest
  environment: master 