From 55894dac01b94424f433e412b4b4f4d6dbecd538 Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Sat, 12 Aug 2023 00:10:50 -0400 Subject: [PATCH] add Dockerfile, CI --- .github/workflows/build.yaml | 70 ++++++++++++++++++++++++++++++++++++ Dockerfile | 10 ++++++ 2 files changed, 80 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 Dockerfile diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..1e4bed6 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,70 @@ +--- +name: 'Build container' + +on: + workflow_dispatch: + pull_request: + branches: + - main + paths-ignore: + - LICENSE + - README.md + push: + branches: + - main + paths-ignore: + - LICENSE + - README.md + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: classabbyamp/treeless-checkout-action@v1 + + - name: Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ghcr.io/${{ github.repository }} + tags: | + type=sha,prefix= + type=raw,value=latest,enable={{is_default_branch}} + type=raw,value={{date 'YYYYMMDD'}},enable={{is_default_branch}},priority=1000 + flavor: latest=false + labels: | + org.opencontainers.image.source=https://github.com/${{ github.repository }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GCHR + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push images + id: build_and_push + uses: docker/build-push-action@v3 + with: + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..46b0650 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM golang:1.21-alpine as build +WORKDIR /app +COPY go.mod go.sum main.go . +RUN go build -v -o xbps-legacy-sign + +FROM scratch +COPY --from=build /app/xbps-legacy-sign /xbps-legacy-sign +ENTRYPOINT [ "/xbps-legacy-sign", "-private-key", "/secrets/id_rsa", \ + "-passphrase-file", "/secrets/id_rsa_passphrase", "-watch" ] +CMD [ "/pkgs" ]