diff --git a/.github/workflows/main-docker-all.yml b/.github/workflows/main-docker-all.yml index 0b99c32..e1cfe3f 100644 --- a/.github/workflows/main-docker-all.yml +++ b/.github/workflows/main-docker-all.yml @@ -56,4 +56,6 @@ jobs: ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} ghcr.io/${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:v2 ghcr.io/${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest - ghcr.io/${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} \ No newline at end of file + ghcr.io/${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index af7aeea..8e255b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,18 @@ -FROM golang:alpine AS builder +FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx -RUN apk add build-base -COPY . /src -RUN cd /src/cmd/WatchYourLAN/ && CGO_ENABLED=0 go build -o /WatchYourLAN . +FROM --platform=$BUILDPLATFORM golang:alpine AS builder + +COPY --from=xx / / + +WORKDIR /src + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +ARG TARGETPLATFORM +RUN CGO_ENABLED=0 xx-go build -ldflags='-w -s' -o /WatchYourLAN ./cmd/WatchYourLAN FROM alpine @@ -14,4 +24,4 @@ RUN apk add --no-cache arp-scan tzdata \ COPY --from=builder /WatchYourLAN /app/ -ENTRYPOINT ["./WatchYourLAN"] \ No newline at end of file +ENTRYPOINT ["./WatchYourLAN"]