diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 23b9ed602..9be444b25 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -5,19 +5,23 @@ on: tags: - 'v*' +permissions: + contents: read + packages: write + jobs: docker-build: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to Github Packages - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} @@ -25,19 +29,20 @@ jobs: - name: Docker meta id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: ghcr.io/swaggo/swag - name: Build image and push to GitHub Container Registry - uses: docker/build-push-action@v2 + id: docker_build + uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64 push: true tags: | - ghcr.io/swaggo/swag:latest - ghcr.io/swaggo/swag:${{github.ref_name}} + ghcr.io/${{ github.repository }}:latest + ghcr.io/${{ github.repository }}:${{github.ref_name}} labels: ${{ steps.meta.outputs.labels }} - name: Image digest diff --git a/Dockerfile b/Dockerfile index dc7c4c621..a9c2b2c6e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,8 @@ RUN go mod download COPY . . # Configure go compiler target platform -ARG TARGETARCH TARGETOS +ARG TARGETOS +ARG TARGETARCH ENV GOARCH=$TARGETARCH \ GOOS=$TARGETOS @@ -25,7 +26,7 @@ RUN CGO_ENABLED=0 GOOS=linux go build -v -a -installsuffix cgo -o swag cmd/swag/ ######## Start a new stage from scratch ####### -FROM scratch +FROM --platform=$TARGETPLATFORM scratch WORKDIR /code/