Skip to content

Commit 3fd795a

Browse files
authored
chore: build the release on ubuntu 22.04 (#290)
Signed-off-by: Keming <[email protected]>
1 parent 3f2d31e commit 3fd795a

File tree

4 files changed

+67
-16
lines changed

4 files changed

+67
-16
lines changed

.github/workflows/CI.yml

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ jobs:
6060
- name: Test
6161
run: cargo test
6262

63-
# Publish latest and releases (e.g. tags with semver).
64-
docker-build-push-release:
63+
docker-build-push:
6564
needs: [ test ]
66-
runs-on: ubuntu-latest
65+
strategy:
66+
matrix:
67+
platform: ["amd64", "arm64"]
68+
runs-on: ${{ matrix.platform == 'amd64' && 'ubuntu-22.04' || 'ubuntu-22.04-arm' }}
6769
permissions:
6870
packages: write # push to ghcr.io
6971
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master'
@@ -76,9 +78,10 @@ jobs:
7678
images: |
7779
ghcr.io/${{ github.repository_owner }}/horust
7880
federicoponzi/horust
81+
flavor: |
82+
latest=false
83+
suffix=-${{ matrix.platform }}
7984
tags: |
80-
type=sha
81-
type=ref,event=branch
8285
type=semver,pattern={{version}}
8386
type=semver,pattern={{major}}.{{minor}}
8487
@@ -103,19 +106,61 @@ jobs:
103106
- name: Build and push images
104107
uses: docker/build-push-action@v6
105108
with:
106-
platforms: linux/amd64,linux/arm64
109+
platforms: linux/${{ matrix.platform }}
107110
labels: ${{ steps.meta.outputs.labels }}
108111
tags: ${{ steps.meta.outputs.tags }}
109112
cache-from: type=gha
110113
cache-to: type=gha,mode=max
111114
push: true
115+
provenance: false # avoid push manifest-list
116+
117+
# amend the platform tag for docker images
118+
docker-manifests:
119+
needs: ["docker-build-push"]
120+
runs-on: ubuntu-latest
121+
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master'
122+
permissions:
123+
packages: write # push to ghcr.io
124+
steps:
125+
- name: Login to Docker Hub
126+
uses: docker/login-action@v3
127+
with:
128+
username: ${{ secrets.DOCKER_USERNAME }}
129+
password: ${{ secrets.DOCKER_PASSWORD }}
130+
- name: Login to GHCR
131+
uses: docker/login-action@v3
132+
with:
133+
registry: ghcr.io
134+
username: ${{ github.repository_owner }}
135+
password: ${{ secrets.GITHUB_TOKEN }}
136+
- name: Get the semver
137+
id: semver
138+
run: |
139+
VERSION="${{ github.ref_name }}"
140+
SEMVER="${VERSION#v}"
141+
echo "semver=${SEMVER}" >> "$GITHUB_OUTPUT"
142+
- name: Create manifests
143+
run: |
144+
AMD_TAG=${{ steps.semver.outputs.semver }}-amd64
145+
ARM_TAG=${{ steps.semver.outputs.semver }}-arm64
146+
SEMVER=${{ steps.semver.outputs.semver }}
147+
docker manifest create \
148+
ghcr.io/${{ github.repository_owner }}/horust:${SEMVER} \
149+
--amend ghcr.io/${{ github.repository_owner }}/horust:${AMD_TAG} \
150+
--amend ghcr.io/${{ github.repository_owner }}/horust:${ARM_TAG}
151+
docker manifest push ghcr.io/${{ github.repository_owner }}/horust:${SEMVER}
152+
docker manifest create \
153+
federicoponzi/horust:${SEMVER} \
154+
--amend federicoponzi/horust:${AMD_TAG} \
155+
--amend federicoponzi/horust:${ARM_TAG}
156+
docker manifest push federicoponzi/horust:${SEMVER}
112157
113158
## This will create a new release in github/releases page. It will run only for tags with semver format.
114159
create-release:
115160
name: deploy
116161
needs: [ test ]
117162
if: startsWith(github.ref, 'refs/tags/')
118-
runs-on: ubuntu-latest
163+
runs-on: ubuntu-22.04 # glibc 2.35
119164
strategy:
120165
matrix:
121166
target:

Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
FROM rust:1 AS builder
1+
FROM rust:1-bookworm AS builder
22
WORKDIR /usr/src/myapp
33
COPY . .
4+
45
ARG CARGO_PARAMS
56
ARG GIT_COMMIT
67
ARG GIT_BRANCH
78
ARG IMAGE_NAME
8-
RUN apt-get update && apt-get install -y protobuf-compiler
99

10+
RUN apt-get update && apt-get install -y protobuf-compiler
1011
RUN echo "Running cargo build with params: $CARGO_PARAMS" && cargo build --release $CARGO_PARAMS
1112

1213
FROM debian:bookworm-slim
14+
15+
ARG CARGO_PARAMS
16+
ARG GIT_COMMIT
17+
ARG GIT_BRANCH
18+
1319
COPY --from=builder /usr/src/myapp/target/release/horust /sbin/horust
1420
RUN mkdir -p /etc/horust/services/ && apt-get update && apt-get install bash
15-
ENV HORUST_LOG info
21+
ENV HORUST_LOG=info
1622
ENV GIT_COMMIT=$GIT_COMMIT
1723
ENV GIT_BRANCH=$GIT_BRANCH
1824
ENV CARGO_PARAMS=$CARGO_PARAMS

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ dargo-run-container: ## Runs a Rust container with the pwd (i.e. current folder)
6464
@docker run \
6565
--detach \
6666
--tty \
67-
--name $(LOCAL_DEV_CONTAINER_NAME) \
68-
--workdir $(LOCAL_DEV_WORKDIR) \
69-
--mount type=bind,source="$(shell pwd)",target=$(LOCAL_DEV_WORKDIR) \
70-
rust:1
67+
--name $(LOCAL_DEV_CONTAINER_NAME) \
68+
--workdir $(LOCAL_DEV_WORKDIR) \
69+
--mount type=bind,source="$(shell pwd)",target=$(LOCAL_DEV_WORKDIR) \
70+
rust:1

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[<img src="https://github.com/FedericoPonzi/Horust/raw/master/res/horust-logo.png" width="300" align="center">](https://github.com/FedericoPonzi/Horust/raw/master/res/horust-logo.png)
22

3-
[![CI](https://github.com/FedericoPonzi/horust/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/FedericoPonzi/Horust/actions?query=workflow%3ACI) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
3+
[![CI](https://github.com/FedericoPonzi/horust/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/FedericoPonzi/Horust/actions?query=workflow%3ACI) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.txt)
44

55
[Horust](https://github.com/FedericoPonzi/Horust) is a supervisor / init system written in rust and designed to be run
66
inside containers.
@@ -206,4 +206,4 @@ at [CONTRIBUTING.md](https://github.com/FedericoPonzi/Horust/blob/master/CONTRIB
206206
## License
207207

208208
Horust is provided under the MIT license. Please read the
209-
attached [license](https://github.com/FedericoPonzi/horust/blob/master/LICENSE) file.
209+
attached [license](https://github.com/FedericoPonzi/horust/blob/master/LICENSE.txt) file.

0 commit comments

Comments
 (0)