Skip to content

Instantly share code, notes, and snippets.

@ftwr
Forked from balintsera/.gitlab-ci.yml
Created June 12, 2020 15:29
Show Gist options
  • Save ftwr/e91c391b2d78c27a9cc2914c7b0e490e to your computer and use it in GitHub Desktop.
Save ftwr/e91c391b2d78c27a9cc2914c7b0e490e to your computer and use it in GitHub Desktop.

Revisions

  1. @balintsera balintsera revised this gist Jun 25, 2018. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -42,6 +42,9 @@ test:
    - docker run -d --add-host 'localhost localhost.localdomain localtest:127.0.0.1' -v ${ERROR_PATH}:/app/tests/_output --name ${CONTAINER_NAME} ${IMAGE}
    # actually run tests
    - docker exec ${CONTAINER_NAME} /app/runtests.sh
    only:
    - master
    - production


    deploy_stage:
  2. @balintsera balintsera revised this gist Jun 25, 2018. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -29,6 +29,21 @@ build:
    - master
    - production

    test:
    type: test
    variables:
    ERROR_PATH: /tmp/example_pipeline_testresults
    tags:
    - docker-in-docker-builder
    script:
    # created directory for errored pages
    - mkdir -p ${ERROR_PATH} || true
    # start the previously built container
    - docker run -d --add-host 'localhost localhost.localdomain localtest:127.0.0.1' -v ${ERROR_PATH}:/app/tests/_output --name ${CONTAINER_NAME} ${IMAGE}
    # actually run tests
    - docker exec ${CONTAINER_NAME} /app/runtests.sh


    deploy_stage:
    type: deploy
    variables:
  3. @balintsera balintsera revised this gist Jun 25, 2018. 1 changed file with 13 additions and 13 deletions.
    26 changes: 13 additions & 13 deletions .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,13 @@
    image: dev.e-vista.hu:5000/docker-builder:latest
    image: customregistry/docker-builder:latest

    variables:
    dockerTag: '$CI_BUILD_REF'
    EVISTA_DOCKER_REPO: dev.e-vista.hu:5000
    IMAGE_BASE_NAME: fotokonyv/photobook-redis-cache
    DOCKER_REPO: customregistry
    IMAGE_BASE_NAME: redis-faas
    IMAGE: $EVISTA_DOCKER_REPO/$IMAGE_BASE_NAME:$CI_BUILD_REF
    CONTAINER_NAME: 'fotok-redis-pipeline'
    TARGET_DIR_STAGE: /srv/docker/staging/micros/redis-cache
    TARGET_DIR_PROD: /srv/docker/prod/micros/redis-cache
    TARGET_DIR_STAGE: /srv/docker/staging/redis-faas
    TARGET_DIR_PROD: /srv/docker/prod/redis-faas


    before_script:
    @@ -32,7 +32,7 @@ build:
    deploy_stage:
    type: deploy
    variables:
    RELEASE_IMAGE: $EVISTA_DOCKER_REPO/$IMAGE_BASE_NAME:latest
    RELEASE_IMAGE: $DOCKER_REPO/$IMAGE_BASE_NAME:latest
    DOCKER_COMPOSE_CMD: cd $TARGET_DIR_STAGE && docker-compose
    tags:
    - docker-in-docker-builder
    @@ -44,16 +44,16 @@ deploy_stage:
    - docker tag $IMAGE $RELEASE_IMAGE
    - docker --tlscacert cert.ca push $RELEASE_IMAGE
    # deploy the images
    - ssh [email protected] -p2223 "docker pull $RELEASE_IMAGE"
    - ssh [email protected] -p2223 "${DOCKER_COMPOSE_CMD} stop"
    - ssh [email protected] -p2223 "${DOCKER_COMPOSE_CMD} up -d"
    - ssh [email protected] -p2224 "docker pull $RELEASE_IMAGE"
    - ssh [email protected] -p2224 "${DOCKER_COMPOSE_CMD} stop"
    - ssh [email protected] -p2224 "${DOCKER_COMPOSE_CMD} up -d"
    only:
    - master

    deploy_production:
    type: deploy
    variables:
    RELEASE_IMAGE: $EVISTA_DOCKER_REPO/$IMAGE_BASE_NAME:stable
    RELEASE_IMAGE: $DOCKER_REPO/$IMAGE_BASE_NAME:stable
    DOCKER_COMPOSE_CMD: cd $TARGET_DIR_PROD && docker-compose
    tags:
    - docker-in-docker-builder
    @@ -65,8 +65,8 @@ deploy_production:
    - docker tag $IMAGE $RELEASE_IMAGE
    - docker --tlscacert cert.ca push $RELEASE_IMAGE
    # deploy the images
    - ssh [email protected] -p2223 "docker pull $RELEASE_IMAGE"
    - ssh [email protected] -p2223 "${DOCKER_COMPOSE_CMD} stop"
    - ssh [email protected] -p2223 "${DOCKER_COMPOSE_CMD} up -d"
    - ssh [email protected] -p2224 "docker pull $RELEASE_IMAGE"
    - ssh [email protected] -p2224 "${DOCKER_COMPOSE_CMD} stop"
    - ssh [email protected] -p2224 "${DOCKER_COMPOSE_CMD} up -d"
    only:
    - production
  4. @balintsera balintsera created this gist Jun 25, 2018.
    72 changes: 72 additions & 0 deletions .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,72 @@
    image: dev.e-vista.hu:5000/docker-builder:latest

    variables:
    dockerTag: '$CI_BUILD_REF'
    EVISTA_DOCKER_REPO: dev.e-vista.hu:5000
    IMAGE_BASE_NAME: fotokonyv/photobook-redis-cache
    IMAGE: $EVISTA_DOCKER_REPO/$IMAGE_BASE_NAME:$CI_BUILD_REF
    CONTAINER_NAME: 'fotok-redis-pipeline'
    TARGET_DIR_STAGE: /srv/docker/staging/micros/redis-cache
    TARGET_DIR_PROD: /srv/docker/prod/micros/redis-cache


    before_script:
    - echo $dockerTag
    - echo $DOCKER_CERT > cert.ca
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$ID_RSA")
    - mkdir -p ~/.ssh
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

    build:
    type: build
    tags:
    - docker-in-docker-pure-builder
    script:
    # build test images
    - docker build -t $IMAGE .
    only:
    - master
    - production

    deploy_stage:
    type: deploy
    variables:
    RELEASE_IMAGE: $EVISTA_DOCKER_REPO/$IMAGE_BASE_NAME:latest
    DOCKER_COMPOSE_CMD: cd $TARGET_DIR_STAGE && docker-compose
    tags:
    - docker-in-docker-builder
    script:
    # tag the final image (the previous test image is built upon the test image file)
    - docker tag $IMAGE $IMAGE
    - docker --tlscacert cert.ca push $IMAGE
    # tag the full image as lastest and push it
    - docker tag $IMAGE $RELEASE_IMAGE
    - docker --tlscacert cert.ca push $RELEASE_IMAGE
    # deploy the images
    - ssh [email protected] -p2223 "docker pull $RELEASE_IMAGE"
    - ssh [email protected] -p2223 "${DOCKER_COMPOSE_CMD} stop"
    - ssh [email protected] -p2223 "${DOCKER_COMPOSE_CMD} up -d"
    only:
    - master

    deploy_production:
    type: deploy
    variables:
    RELEASE_IMAGE: $EVISTA_DOCKER_REPO/$IMAGE_BASE_NAME:stable
    DOCKER_COMPOSE_CMD: cd $TARGET_DIR_PROD && docker-compose
    tags:
    - docker-in-docker-builder
    script:
    # tag the final image (the previous test image is built upon the test image file)
    - docker tag $IMAGE $IMAGE
    - docker --tlscacert cert.ca push $IMAGE
    # tag the full image as lastest and push it
    - docker tag $IMAGE $RELEASE_IMAGE
    - docker --tlscacert cert.ca push $RELEASE_IMAGE
    # deploy the images
    - ssh [email protected] -p2223 "docker pull $RELEASE_IMAGE"
    - ssh [email protected] -p2223 "${DOCKER_COMPOSE_CMD} stop"
    - ssh [email protected] -p2223 "${DOCKER_COMPOSE_CMD} up -d"
    only:
    - production