Skip to content

Commit

Permalink
Try add github actions for docker build and switch to buildah for gitlab
Browse files Browse the repository at this point in the history
  • Loading branch information
Moulick committed Oct 11, 2021
1 parent 538d643 commit a99bc5b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 21 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: ci

on:
push:
branches:
- 'master'

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: moulick/debug-image:latest
cache-from: type=registry,ref=moulick/debug-image:buildcache
cache-to: type=registry,ref=moulick/debug-image:buildcache,mode=max
40 changes: 19 additions & 21 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
docker-build-master:
image: docker:latest
stage: build
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker push "$CI_REGISTRY_IMAGE"
only:
- master

docker-build:
image: docker:latest
stages:
- build

default:
tags:
- kubernetes

buildah-build:
stage: build
services:
- docker:dind
variables:
STORAGE_DRIVER: vfs
image:
name: quay.io/buildah/stable:latest
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- buildah login -u "$CI_REGISTRY_USER" -p "$CI_JOB_TOKEN" "$CI_REGISTRY"
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
except:
- master
- buildah bud
-t "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}"
-f Dockerfile
- buildah tag "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}" "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}"
- buildah push "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}"
- buildah push "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}"

0 comments on commit a99bc5b

Please sign in to comment.