refactor(ci): simplify CI configuration by consolidating binary build steps and updating Dockerfile

This commit is contained in:
Félix MARQUET
2025-06-13 13:55:10 +02:00
parent 60db3550c0
commit fe33377fa0
7 changed files with 47 additions and 202 deletions

View File

@@ -6,18 +6,8 @@ on:
- dev
jobs:
build-binaries:
build-binary:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: x86_64-unknown-linux-musl
platform: linux/amd64
name: github-ntfy-amd64
- target: aarch64-unknown-linux-musl
platform: linux/arm64
name: github-ntfy-arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -26,7 +16,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
target: x86_64-unknown-linux-musl
override: true
- name: Installer cross
@@ -49,32 +39,27 @@ jobs:
RUSTFLAGS: "-C target-feature=+crt-static"
OPENSSL_NO_VENDOR: 0
run: |
cross build --release --target ${{ matrix.target }} --features vendored-openssl
cross build --release --target x86_64-unknown-linux-musl --features vendored-openssl
- name: Préparer le binaire
run: |
mkdir -p release
cp target/${{ matrix.target }}/release/github-ntfy release/${{ matrix.name }}
cp target/x86_64-unknown-linux-musl/release/github-ntfy release/github-ntfy
- name: Upload binaire comme artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: release/${{ matrix.name }}
name: github-ntfy
path: release/github-ntfy
docker-build-push:
needs: [ build-binaries ]
needs: [build-binary]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configurer QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Configurer Docker Buildx
- name: Configurer Docker
uses: docker/setup-buildx-action@v3
- name: Login Docker Hub
@@ -83,60 +68,20 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Télécharger tous les binaires
- name: Télécharger le binaire
uses: actions/download-artifact@v4
with:
name: github-ntfy
path: binaries
- name: Préparer les binaires pour Docker
- name: Préparer le binaire pour Docker
run: |
mkdir -p binaries-docker
cp binaries/github-ntfy-amd64/github-ntfy-amd64 binaries-docker/
cp binaries/github-ntfy-arm64/github-ntfy-arm64 binaries-docker/
chmod +x binaries-docker/*
chmod +x binaries/github-ntfy
- name: Créer Dockerfile spécifique pour chaque architecture
run: |
# Créer un Dockerfile séparé pour chaque architecture
cat > Dockerfile.multi << 'EOF'
FROM --platform=${TARGETPLATFORM} alpine:3.22
ARG TARGETPLATFORM
ARG TARGETARCH
ARG TARGETVARIANT
# Copier le binaire approprié selon l'architecture
COPY binaries-docker/github-ntfy-amd64 /usr/local/bin/github-ntfy-amd64
COPY binaries-docker/github-ntfy-arm64 /usr/local/bin/github-ntfy-arm64
# Installer des outils pour débogage et déplacer le bon binaire
RUN apk add --no-cache sqlite-libs openssl nginx && \
if [ "$TARGETARCH" = "amd64" ]; then \
cp /usr/local/bin/github-ntfy-amd64 /usr/local/bin/github-ntfy; \
elif [ "$TARGETARCH" = "arm64" ]; then \
cp /usr/local/bin/github-ntfy-arm64 /usr/local/bin/github-ntfy; \
fi && \
chmod +x /usr/local/bin/github-ntfy && \
rm /usr/local/bin/github-ntfy-*
WORKDIR /app
COPY web /app/web
COPY config.toml /app/config.toml
ENV DB_PATH=/data
VOLUME /data
EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/github-ntfy"]
CMD ["--config", "/app/config.toml"]
EOF
- name: Construire et pousser l'image Docker multi-architecture
- name: Construire et pousser l'image Docker
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
breizhhardware/github-ntfy:dev
file: Dockerfile.multi
tags: breizhhardware/github-ntfy:dev
file: Dockerfile

View File

@@ -40,15 +40,6 @@ jobs:
build-binaries:
needs: version
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: x86_64-unknown-linux-musl
platform: linux/amd64
name: github-ntfy-amd64
- target: aarch64-unknown-linux-musl
platform: linux/arm64
name: github-ntfy-arm64
steps:
- name: Checkout code
@@ -58,13 +49,13 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
target: x86_64-unknown-linux-musl
override: true
- name: Installer cross
run: cargo install cross
- name: Créer Cross.toml pour spécifier OpenSSL statique
- name: Créer Cross.toml pour spécifier OpenSSL vendored
run: |
cat > Cross.toml << 'EOF'
[build.env]
@@ -75,24 +66,24 @@ jobs:
]
EOF
- name: Construire avec cross
- name: Construire avec cross et OpenSSL vendored
env:
OPENSSL_STATIC: 1
RUSTFLAGS: "-C target-feature=+crt-static"
OPENSSL_NO_VENDOR: 0
run: |
cross build --release --target ${{ matrix.target }} --features vendored-openssl
cross build --release --target x86_64-unknown-linux-musl --features vendored-openssl
- name: Préparer le binaire
run: |
mkdir -p release
cp target/${{ matrix.target }}/release/github-ntfy release/${{ matrix.name }}
cp target/x86_64-unknown-linux-musl/release/github-ntfy release/github-ntfy
- name: Upload binaire comme artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: release/${{ matrix.name }}
name: github-ntfy
path: release/github-ntfy
docker-build-push:
needs: [version, build-binaries]
@@ -101,11 +92,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Configurer QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Configurer Docker Buildx
uses: docker/setup-buildx-action@v3
@@ -118,27 +104,23 @@ jobs:
- name: Télécharger tous les binaires
uses: actions/download-artifact@v4
with:
name: github-ntfy
path: binaries
- name: Préparer les binaires pour Docker
- name: Préparer le binaire pour Docker
run: |
mkdir -p binaries-docker
cp binaries/github-ntfy-amd64/github-ntfy-amd64 binaries-docker/
cp binaries/github-ntfy-arm64/github-ntfy-arm64 binaries-docker/
chmod +x binaries-docker/*
ls -la binaries-docker/
chmod +x binaries/github-ntfy
# Construire et pousser l'image multi-architecture
- name: Construire et pousser l'image Docker multi-architecture
- name: Construire et pousser l'image Docker
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
breizhhardware/github-ntfy:latest
breizhhardware/github-ntfy:${{ needs.version.outputs.version }}
file: Dockerfile.multi
file: Dockerfile
create-release:
needs: [version, build-binaries]
@@ -150,6 +132,7 @@ jobs:
- name: Télécharger tous les binaires
uses: actions/download-artifact@v4
with:
name: github-ntfy
path: binaries
- name: Créer une release GitHub
@@ -158,8 +141,7 @@ jobs:
tag_name: ${{ needs.version.outputs.version }}
name: Release ${{ needs.version.outputs.version }}
files: |
binaries/github-ntfy-amd64/github-ntfy-amd64
binaries/github-ntfy-arm64/github-ntfy-arm64
binaries/github-ntfy
draft: false
prerelease: false
generate_release_notes: true

3
.gitignore vendored
View File

@@ -410,3 +410,6 @@ github-ntfy/*
# Rust
target
target/*
binaries
binaries/*

View File

@@ -1,63 +1,25 @@
FROM 1.87.0-alpine3.22 as builder
FROM alpine:3.22
LABEL maintainer="BreizhHardware"
LABEL version_number="1.4"
# Copier le binaire
COPY binaries/github-ntfy /usr/local/bin/github-ntfy
# Installer les dépendances
RUN apk add --no-cache sqlite-libs openssl nginx && \
chmod +x /usr/local/bin/github-ntfy
WORKDIR /app
# Installation of dependencies
RUN apk add --no-cache sqlite-dev musl-dev openssl-dev pkgconfig
# Copy of the source files
COPY Cargo.toml Cargo.lock ./
# Create a temp source file to pre download dependencies
RUN mkdir src && \
echo "fn main() {}" > src/main.rs && \
cargo build --release && \
rm -rf src
# Copy real file
COPY src/ ./src/
# Build the application
RUN cargo build --release
# Final image
FROM alpine:3.22
# Install of runtime dependencies
RUN apk add --no-cache sqlite-libs openssl nginx
# Copy the static files
COPY index.html /var/www/html/index.html
COPY script.js /var/www/html/script.js
# Copy the built application from the builder stage
COPY --from=builder /app/target/release/github-ntfy /usr/local/bin/github-ntfy
# Configure Nginx
# Copier les fichiers web dans le répertoire attendu par nginx
COPY web/* /var/www/html/
COPY nginx.conf /etc/nginx/nginx.conf
# Copy the entrypoint script
COPY entrypoint.sh /
RUN chmod 700 /entrypoint.sh
# Define the working directory
ENV USERNAME="" \
PASSWORD="" \
NTFY_URL="" \
GHNTFY_TIMEOUT="3600" \
GHNTFY_TOKEN="" \
DOCKER_USERNAME="" \
DOCKER_PASSWORD="" \
GOTIFY_URL="" \
GOTIFY_TOKEN="" \
DISCORD_WEBHOOK_URL="" \
SLACK_WEBHOOK_URL=""
# Copier le script d'entrée
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# Créer le répertoire de données
RUN mkdir -p /github-ntfy && chmod 755 /github-ntfy
EXPOSE 5000 80
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/app/entrypoint.sh"]

View File

@@ -1,47 +0,0 @@
FROM alpine:3.22 AS base
# Copier les binaires précompilés selon l'architecture
COPY binaries-docker/github-ntfy-amd64 /usr/local/bin/github-ntfy-amd64
COPY binaries-docker/github-ntfy-arm64 /usr/local/bin/github-ntfy-arm64
# Installation des dépendances et configuration du binaire selon l'architecture
RUN apk add --no-cache sqlite-libs openssl nginx && \
if [ "$(uname -m)" = "x86_64" ]; then \
cp /usr/local/bin/github-ntfy-amd64 /usr/local/bin/github-ntfy; \
elif [ "$(uname -m)" = "aarch64" ]; then \
cp /usr/local/bin/github-ntfy-arm64 /usr/local/bin/github-ntfy; \
fi && \
chmod +x /usr/local/bin/github-ntfy && \
rm /usr/local/bin/github-ntfy-*
WORKDIR /app
# Copier les fichiers statiques
COPY index.html /var/www/html/index.html
COPY script.js /var/www/html/script.js
# Copier la configuration nginx
COPY nginx.conf /etc/nginx/nginx.conf
# Copier le script d'entrée
COPY entrypoint.sh /
RUN chmod 700 /entrypoint.sh
# Variables d'environnement
ENV USERNAME="" \
PASSWORD="" \
NTFY_URL="" \
GHNTFY_TIMEOUT="3600" \
GHNTFY_TOKEN="" \
DOCKER_USERNAME="" \
DOCKER_PASSWORD="" \
GOTIFY_URL="" \
GOTIFY_TOKEN="" \
DISCORD_WEBHOOK_URL="" \
SLACK_WEBHOOK_URL=""
RUN mkdir -p /github-ntfy && chmod 755 /github-ntfy
EXPOSE 8080 80
ENTRYPOINT ["/entrypoint.sh"]

View File

@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Github-Ntfy Add a Repo</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="./script.js" defer></script>
<script src="script.js" defer></script>
</head>
<body class="bg-[#1b2124] text-gray-200">
<header class="text-center py-8 bg-[#23453d] shadow-lg">