diff --git a/Dockerfile b/Dockerfile index a9be399..34dc4c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,22 +2,26 @@ FROM golang:1.23-bullseye AS deps WORKDIR /app COPY go.mod go.sum ./ -RUN go mod download +RUN --mount=type=cache,target=/go/pkg/mod \ + go mod download FROM golang:1.23-bullseye AS build WORKDIR /app COPY --from=deps /go/pkg/mod /go/pkg/mod COPY . . -RUN apt-get update && apt-get install -y gcc g++ +RUN --mount=type=cache,target=/var/cache/apt \ + apt-get update && apt-get install -y gcc g++ ENV CGO_ENABLED=1 \ GOOS=linux \ GOARCH=amd64 -RUN go build -o /app/bin/sentinel ./ +RUN --mount=type=cache,target=/root/.cache/go-build \ + go build -o /app/bin/sentinel ./ FROM debian:bullseye-slim -RUN apt-get update && apt-get install -y ca-certificates curl && rm -rf /var/lib/apt/lists/* +RUN --mount=type=cache,target=/var/cache/apt \ + apt-get update && apt-get install -y ca-certificates curl && rm -rf /var/lib/apt/lists/* ENV GIN_MODE=release COPY --from=build /app/ /app COPY --from=build /app/bin/sentinel /app/sentinel diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index ac5f4f8..bef206b 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -2,22 +2,26 @@ FROM golang:1.23-bullseye AS deps WORKDIR /app COPY go.mod go.sum ./ -RUN go mod download +RUN --mount=type=cache,target=/go/pkg/mod \ + go mod download FROM golang:1.23-bullseye AS build WORKDIR /app COPY --from=deps /go/pkg/mod /go/pkg/mod COPY . . -RUN apt-get update && apt-get install -y gcc g++ +RUN --mount=type=cache,target=/var/cache/apt \ + apt-get update && apt-get install -y gcc g++ ENV CGO_ENABLED=1 \ GOOS=linux \ GOARCH=arm64 -RUN go build -o /app/bin/sentinel ./ +RUN --mount=type=cache,target=/root/.cache/go-build \ + go build -o /app/bin/sentinel ./ FROM debian:bullseye-slim -RUN apt-get update && apt-get install -y ca-certificates curl && rm -rf /var/lib/apt/lists/* +RUN --mount=type=cache,target=/var/cache/apt \ + apt-get update && apt-get install -y ca-certificates curl && rm -rf /var/lib/apt/lists/* ENV GIN_MODE=release COPY --from=build /app/ /app COPY --from=build /app/bin/sentinel /app/sentinel