Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 52 additions & 7 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ jobs:
- name: Test
run: cargo test

# Publish latest and releases (e.g. tags with semver).
docker-build-push-release:
docker-build-push:
needs: [ test ]
runs-on: ubuntu-latest
strategy:
matrix:
platform: ["amd64", "arm64"]
runs-on: ${{ matrix.platform == 'amd64' && 'ubuntu-22.04' || 'ubuntu-22.04-arm' }}
permissions:
packages: write # push to ghcr.io
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master'
Expand All @@ -76,9 +78,10 @@ jobs:
images: |
ghcr.io/${{ github.repository_owner }}/horust
federicoponzi/horust
flavor: |
latest=false
suffix=-${{ matrix.platform }}
tags: |
type=sha
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

Expand All @@ -103,19 +106,61 @@ jobs:
- name: Build and push images
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
platforms: linux/${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
provenance: false # avoid push manifest-list

# amend the platform tag for docker images
docker-manifests:
needs: ["docker-build-push"]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master'
permissions:
packages: write # push to ghcr.io
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get the semver
id: semver
run: |
VERSION="${{ github.ref_name }}"
SEMVER="${VERSION#v}"
echo "semver=${SEMVER}" >> "$GITHUB_OUTPUT"
Comment on lines +136 to +141
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope I can get the tags from ${{ needs.docker-build-push.meta.tags }}, but GitHub doesn't support outputs from the specific matrix. See https://github.com/orgs/community/discussions/17245

- name: Create manifests
run: |
AMD_TAG=${{ steps.semver.outputs.semver }}-amd64
ARM_TAG=${{ steps.semver.outputs.semver }}-arm64
SEMVER=${{ steps.semver.outputs.semver }}
docker manifest create \
ghcr.io/${{ github.repository_owner }}/horust:${SEMVER} \
--amend ghcr.io/${{ github.repository_owner }}/horust:${AMD_TAG} \
--amend ghcr.io/${{ github.repository_owner }}/horust:${ARM_TAG}
docker manifest push ghcr.io/${{ github.repository_owner }}/horust:${SEMVER}
docker manifest create \
federicoponzi/horust:${SEMVER} \
--amend federicoponzi/horust:${AMD_TAG} \
--amend federicoponzi/horust:${ARM_TAG}
docker manifest push federicoponzi/horust:${SEMVER}

## This will create a new release in github/releases page. It will run only for tags with semver format.
create-release:
name: deploy
needs: [ test ]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
runs-on: ubuntu-22.04 # glibc 2.35
strategy:
matrix:
target:
Expand Down
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
FROM rust:1 AS builder
FROM rust:1-bookworm AS builder
WORKDIR /usr/src/myapp
COPY . .

ARG CARGO_PARAMS
ARG GIT_COMMIT
ARG GIT_BRANCH
ARG IMAGE_NAME
RUN apt-get update && apt-get install -y protobuf-compiler

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

FROM debian:bookworm-slim

ARG CARGO_PARAMS
ARG GIT_COMMIT
ARG GIT_BRANCH

COPY --from=builder /usr/src/myapp/target/release/horust /sbin/horust
RUN mkdir -p /etc/horust/services/ && apt-get update && apt-get install bash
ENV HORUST_LOG info
ENV HORUST_LOG=info
ENV GIT_COMMIT=$GIT_COMMIT
ENV GIT_BRANCH=$GIT_BRANCH
ENV CARGO_PARAMS=$CARGO_PARAMS
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ dargo-run-container: ## Runs a Rust container with the pwd (i.e. current folder)
@docker run \
--detach \
--tty \
--name $(LOCAL_DEV_CONTAINER_NAME) \
--workdir $(LOCAL_DEV_WORKDIR) \
--mount type=bind,source="$(shell pwd)",target=$(LOCAL_DEV_WORKDIR) \
rust:1
--name $(LOCAL_DEV_CONTAINER_NAME) \
--workdir $(LOCAL_DEV_WORKDIR) \
--mount type=bind,source="$(shell pwd)",target=$(LOCAL_DEV_WORKDIR) \
rust:1
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[<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)

[![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)
[![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)

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

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