mirror of
https://github.com/BreizhHardware/ntfy_alerts.git
synced 2026-01-18 16:37:28 +01:00
147 lines
4.6 KiB
YAML
147 lines
4.6 KiB
YAML
name: Build et Push Docker Dev Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- dev
|
|
|
|
jobs:
|
|
build-binaries:
|
|
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
|
|
|
|
- name: Installer Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
target: ${{ matrix.target }}
|
|
override: true
|
|
|
|
- name: Installer cross
|
|
run: cargo install cross
|
|
|
|
- name: Créer Cross.toml pour spécifier OpenSSL vendored
|
|
run: |
|
|
cat > Cross.toml << 'EOF'
|
|
[build.env]
|
|
passthrough = [
|
|
"RUSTFLAGS",
|
|
"OPENSSL_STATIC",
|
|
"OPENSSL_NO_VENDOR"
|
|
]
|
|
EOF
|
|
|
|
- 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
|
|
|
|
- name: Préparer le binaire
|
|
run: |
|
|
mkdir -p release
|
|
cp target/${{ matrix.target }}/release/github-ntfy release/${{ matrix.name }}
|
|
|
|
- name: Upload binaire comme artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.name }}
|
|
path: release/${{ matrix.name }}
|
|
|
|
docker-build-push:
|
|
needs: [ version, build-binaries ]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Configurer QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: arm64,arm/v7
|
|
|
|
- name: Configurer Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Télécharger tous les binaires
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: binaries
|
|
|
|
- name: Préparer les binaires 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/
|
|
cp binaries/github-ntfy-armv7/github-ntfy-armv7 binaries-docker/
|
|
chmod +x binaries-docker/*
|
|
|
|
- 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
|
|
COPY binaries-docker/github-ntfy-armv7 /usr/local/bin/github-ntfy-armv7
|
|
|
|
# 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; \
|
|
elif [ "$TARGETARCH" = "arm" ] && [ "$TARGETVARIANT" = "v7" ]; then \
|
|
cp /usr/local/bin/github-ntfy-armv7 /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
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
tags: |
|
|
${{ secrets.DOCKER_USERNAME }}/github-ntfy:dev
|
|
${{ secrets.DOCKER_USERNAME }}/github-ntfy:${{ needs.version.outputs.version }}
|
|
file: Dockerfile.multi |