Skip to content

Commit

Permalink
enhanced docker image builds
Browse files Browse the repository at this point in the history
  • Loading branch information
DenuxPlays committed Dec 13, 2024
1 parent dbb2aa6 commit c8702f5
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 98 deletions.
98 changes: 0 additions & 98 deletions .github/workflows/backend-publish-docker-images.yaml

This file was deleted.

63 changes: 63 additions & 0 deletions .github/workflows/publish-edge-docker-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Publish Edge Docker Images

on:
push:
branches:
- main
paths:
- 'backend/**'

concurrency:
group: "edge-docker-images"
cancel-in-progress: false

env:
REGISTRY: ghcr.io

jobs:
backend-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
IMAGE_NAME: jt-foss/backend
# Set default working directory
defaults:
run:
working-directory: ./backend # Change the working directory to /backend
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
type=edge
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./backend
file: ./backend/docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
68 changes: 68 additions & 0 deletions .github/workflows/publish-prod-docker-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Publish Production Docker Images

on:
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
paths:
- 'backend/**'

concurrency:
group: "prod-docker-images"
cancel-in-progress: false

env:
REGISTRY: ghcr.io
IMAGE_NAME: jt-foss/backend

jobs:
backend-image:
if: github.event_name == 'create' && github.event.ref_type == 'tag'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
IMAGE_NAME: jt-foss/backend
# Set default working directory
defaults:
run:
working-directory: ./backend # Change the working directory to /backend
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./backend
file: ./backend/docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit c8702f5

Please sign in to comment.