Skip to content

Commit

Permalink
chore(gha): add build & publish docker image workflow (#8)
Browse files Browse the repository at this point in the history
* chore(gha): add build docker image workflow

Signed-off-by: Kaan Yagci <kaan.yagci@makepad.fr>

* drop: temporary remove the path constraints

Signed-off-by: Kaan Yagci <kaan.yagci@makepad.fr>

* refactor(gha): rename GHA workflow

Signed-off-by: Kaan Yagci <kaan.yagci@makepad.fr>

* fix(gha): invalid tag

Signed-off-by: Kaan Yagci <kaan.yagci@makepad.fr>

* chore: update Dockerfile with DEBIAN_TAG

Signed-off-by: Kaan Yagci <kaan.yagci@makepad.fr>

* chore(gha): update build workflow

Signed-off-by: Kaan Yagci <kaan.yagci@makepad.fr>

* fix(gha): invalid image tag issue

Signed-off-by: Kaan Yagci <kaan.yagci@makepad.fr>

---------

Signed-off-by: Kaan Yagci <kaan.yagci@makepad.fr>
  • Loading branch information
kaanyagci authored May 2, 2024
1 parent 9915261 commit 377cb3e
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
57 changes: 57 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build and Push Docker Image

on:
release:
types:
- published
- edited

pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
paths:
- core/**
- forward-proxy/**
- Dockerfile
- Makefile

concurrency:
group: "${{ github.workflow }}-${{ github.ref_name }}-${{ github.event_name }}"
cancel-in-progress: true

jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
DEBIAN_TAG: ["trixie", "trixie-slim", "bullseye", "bullseye-slim", "buster", "buster-slim", "bookworm-slim", "bookworm"]
steps:
- name: Checkout Repo
uses: actions/checkout@v4.1.2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.2.0

- name: Login to DockerHub
if: github.event_name == 'release'
uses: docker/login-action@v3.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and Push Docker image
uses: docker/build-push-action@v5.3.0
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64/v8
push: ${{ github.event_name == 'release' }}
tags: makepad/sfp:${{ (github.event_name == 'release' && github.event.release.tag_name) || github.sha }}-${{ matrix.DEBIAN_TAG }}
build-args: |
DEBIAN_TAG=${{ matrix.DEBIAN_TAG }}
cache-from: type=registry,ref=makepad/sfp:${{( github.event_name == 'release' && github.event.release.tag_name) || github.sha }}-${{ matrix.DEBIAN_TAG }}
cache-to: type=inline
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ARG DEBIAN_TAG
FROM golang:1.22.2-bookworm as build

WORKDIR /app
Expand All @@ -11,7 +12,7 @@ COPY ./forward-proxy ./forward-proxy

RUN make build-local

FROM debian:bookworm-slim
FROM debian:${DEBIAN_TAG}

EXPOSE 9090
WORKDIR /app
Expand Down

0 comments on commit 377cb3e

Please sign in to comment.