9iron/.gitlab-ci.yml

63 lines
1.5 KiB
YAML
Raw Normal View History

2021-03-20 13:34:56 -05:00
#
# This guy is awesome: https://dev.to/bzinoun/gitlab-ci-to-build-and-push-containers-to-registry-538a
#
2021-03-20 18:50:45 -05:00
image: morlay/buildx:607a2ce
2021-03-20 13:34:56 -05:00
variables:
# DinD's vfs driver is pretty intensive; this is less so
DOCKER_DRIVER: overlay2
CI_HUB_USERNAME: rehashedsalt
stages:
- build
2021-03-25 01:02:41 -05:00
# - test
2021-08-01 14:47:57 -05:00
- deploy
2021-03-20 13:34:56 -05:00
services:
- docker:dind
before_script:
- echo -n "$CI_LOGIN_PASSWORD" | docker login -u "$CI_LOGIN_USERNAME" --password-stdin
- docker version
- docker info
after_script:
- docker logout hub.docker.com
# BUILD
2021-03-20 13:34:56 -05:00
Build:
stage: build
script:
- docker pull $CI_HUB_USERNAME/$CI_PROJECT_NAME:latest || true
2021-03-20 14:20:43 -05:00
- docker buildx create --use
2021-03-20 13:34:56 -05:00
- >
2021-03-20 14:20:43 -05:00
docker buildx build
2021-03-20 13:34:56 -05:00
--pull
2021-03-20 14:20:43 -05:00
--platform linux/amd64,linux/arm64
2021-03-20 13:34:56 -05:00
--cache-from $CI_HUB_USERNAME/$CI_PROJECT_NAME:latest
--tag $CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA
2021-05-01 15:44:31 -05:00
--tag $CI_HUB_USERNAME/$CI_PROJECT_NAME:bleeding
--push
2021-03-20 13:34:56 -05:00
.
2021-03-20 20:36:24 -05:00
- docker images
2021-05-01 15:44:31 -05:00
Build_Tag:
stage: build
2021-03-20 13:34:56 -05:00
only:
- tags
script:
2021-05-01 15:44:31 -05:00
- docker pull $CI_HUB_USERNAME/$CI_PROJECT_NAME:latest || true
- docker buildx create --use
2021-03-20 13:34:56 -05:00
- >
2021-05-01 15:44:31 -05:00
docker buildx build
--pull
--platform linux/amd64,linux/arm64
--cache-from $CI_HUB_USERNAME/$CI_PROJECT_NAME:latest
--tag $CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_REF_NAME
--tag $CI_HUB_USERNAME/$CI_PROJECT_NAME:latest
--push
.
- docker images
2021-08-01 14:45:52 -05:00
2021-08-01 14:47:57 -05:00
# DEPLOY
Deploy:
stage: deploy
2021-08-01 14:45:52 -05:00
only:
- tags
trigger: rehashedsalt/ansible