Skip to content

Commit 153c240

Browse files
ci: publish Docker image to ghcr.io on release, use pre-built image in docker-compose
- Add docker-publish.yml workflow: builds and pushes to ghcr.io/mes-open/openmes on tag push - Tags: semver (0.12.0), major.minor (0.12), latest - docker-compose.yml: image pulls from ghcr.io by default, falls back to local build - Set OPENMES_VERSION env var to pin a specific version
1 parent 6ca0a54 commit 153c240

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Build & Publish Docker Image
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'Image tag (e.g. v0.12.0 or latest)'
11+
required: false
12+
default: 'latest'
13+
14+
env:
15+
REGISTRY: ghcr.io
16+
IMAGE_NAME: ${{ github.repository_owner }}/openmes
17+
18+
jobs:
19+
build-and-push:
20+
name: Build & Push
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Log in to GitHub Container Registry
31+
uses: docker/login-action@v3
32+
with:
33+
registry: ${{ env.REGISTRY }}
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Extract metadata
38+
id: meta
39+
uses: docker/metadata-action@v5
40+
with:
41+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
42+
tags: |
43+
type=semver,pattern={{version}}
44+
type=semver,pattern={{major}}.{{minor}}
45+
type=raw,value=latest,enable={{is_default_branch}}
46+
type=raw,value=${{ github.event.inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
47+
48+
- name: Set up Docker Buildx
49+
uses: docker/setup-buildx-action@v3
50+
51+
- name: Build and push
52+
uses: docker/build-push-action@v5
53+
with:
54+
context: .
55+
file: backend/Dockerfile
56+
push: true
57+
tags: ${{ steps.meta.outputs.tags }}
58+
labels: ${{ steps.meta.outputs.labels }}
59+
cache-from: type=gha
60+
cache-to: type=gha,mode=max

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ services:
2121
- openmmes-network
2222

2323
backend:
24+
image: ghcr.io/mes-open/openmes:${OPENMES_VERSION:-latest}
2425
build:
2526
context: .
2627
dockerfile: backend/Dockerfile
@@ -56,6 +57,7 @@ services:
5657
# Set MQTT_CONNECTION_ID to the ID from the admin panel.
5758
# Example: MQTT_CONNECTION_ID=1 docker compose up -d mqtt-listener
5859
mqtt-listener:
60+
image: ghcr.io/mes-open/openmes:${OPENMES_VERSION:-latest}
5961
build:
6062
context: .
6163
dockerfile: backend/Dockerfile

0 commit comments

Comments
 (0)