Skip to content

Commit

Permalink
Use buildkit and rebuild deploy workflow (#26)
Browse files Browse the repository at this point in the history
* Use buildkit when building the image

* Rebuilding deploy workflow uses docker/build-push-action

* Name the second stage in the multi-stage build for easier log review

* Bump the version label in the Dockerfile
  • Loading branch information
artis3n authored Jan 3, 2021
1 parent 269c62c commit d372496
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
curl -fsSL https://goss.rocks/install | sudo sh
- run:
name: Build the image
command: make build
command: make build-ci
- run:
name: Goss tests
command: |
Expand Down
63 changes: 38 additions & 25 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,49 @@ jobs:
with:
submodules: true

- name: Deploy the Docker image to GitHub Container Registry - Semver
uses: elgohr/Publish-Docker-Github-Action@master
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
name: artis3n/pgmodeler
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_PAT }}
registry: ghcr.io
tag_semver: true
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Deploy the Docker image to GitHub Container Registry - Latest
uses: elgohr/Publish-Docker-Github-Action@master
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
name: artis3n/pgmodeler
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_PAT }}
registry: ghcr.io
tags: "latest"

- name: Deploy the Docker image to Docker Hub - Semver
uses: elgohr/Publish-Docker-Github-Action@master
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1.11.0
with:
name: artis3n/pgmodeler
username: ${{ secrets.docker_username }}
password: ${{ secrets.docker_password }}
tag_semver: true

- name: Deploy the Docker image to Docker Hub - Latest
uses: elgohr/Publish-Docker-Github-Action@master
images: ghcr.io/artis3n/pgmodeler-container
tag-latest: true
tag-sha: true
tag-semver: |
{{version}}
{{major}}.{{minor}}
{{major}}
- name: Build and Push
uses: docker/build-push-action@v2
with:
name: artis3n/pgmodeler
username: ${{ secrets.docker_username }}
password: ${{ secrets.docker_password }}
tags: "latest"
push: true
context: .
file: ./Dockerfile
build-args: |
--progress plain
tags: ${{ steps.docker_meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
env:
DOCKER_BUILDKIT: 1
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ RUN mkdir /app \
&& make install

# Now that the image is compiled, we can remove most of the image size bloat
FROM ubuntu:20.10
FROM ubuntu:20.10 as app
LABEL Name="artis3n/pgmodeler"
LABEL Version="1.2.1"
LABEL Version="1.3.1"
LABEL maintainer="Artis3n <dev@artis3nal.com>"

ARG DEBIAN_FRONTEND=noninteractive
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ test-edit:

.PHONY: build
build:
docker build . -t artis3n/pgmodeler:$${TAG:-test}
DOCKER_BUILDKIT=1 docker build . -t artis3n/pgmodeler:$${TAG:-test}

.PHONY: build-ci
build-ci:
DOCKER_BUILDKIT=1 docker build --progress plain . -t artis3n/pgmodeler:$${TAG:-test}

.PHONY: run
run:
Expand Down

0 comments on commit d372496

Please sign in to comment.