Skip to content

Instantly share code, notes, and snippets.

@indiejoseph
Created May 14, 2020 04:04
Show Gist options
  • Save indiejoseph/ab4e69eb6c3e1e0668f90bf45e50a1d4 to your computer and use it in GitHub Desktop.
Save indiejoseph/ab4e69eb6c3e1e0668f90bf45e50a1d4 to your computer and use it in GitHub Desktop.
Denzt deployment reference
Prepare Build Image:
stage: prepare build image
cache:
key: ${CI_COMMIT_REF_SLUG}-${CI_PROJECT_DIR}
paths:
- node_modules/
only:
changes:
- .gitlab-ci.yml
- Dockerfile
- package.json
- '**/*.package.json'
- yarn.lock
script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- docker pull ${DEPLOY_IMAGE}:${CI_BUILD_REF_SLUG} || true
- >
docker build
--pull
--cache-from ${DEPLOY_IMAGE}:${CI_BUILD_REF_SLUG}
--build-arg VCS_REF=${CI_COMMIT_SHA}
--build-arg VCS_URL=${CI_PROJECT_URL}
--tag ${DEPLOY_IMAGE}:${CI_BUILD_REF_SLUG}
.
- docker push ${DEPLOY_IMAGE}:${CI_BUILD_REF_SLUG}
Push Latest:
variables:
GIT_STRATEGY: none
stage: push build image
only:
- master
script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- echo -n ${CI_JOB_TOKEN} | docker login -u gitlab-ci-token --password-stdin ${CI_REGISTRY}
- docker pull ${DEPLOY_IMAGE}:${CI_BUILD_REF_SLUG}
- docker tag ${DEPLOY_IMAGE}:${CI_BUILD_REF_SLUG} ${DEPLOY_IMAGE}:latest
- docker push ${DEPLOY_IMAGE}:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment