Merge pull request #180 from gabe565/optimize-docker-build
Optimize Docker build
This commit is contained in:
commit
9b78b7115f
2 changed files with 18 additions and 6 deletions
4
.github/workflows/main-docker-all.yml
vendored
4
.github/workflows/main-docker-all.yml
vendored
|
|
@ -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 }}
|
||||
ghcr.io/${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
|
|
|||
20
Dockerfile
20
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"]
|
||||
ENTRYPOINT ["./WatchYourLAN"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue