Skip to content

Commit

Permalink
chore: add caching to Linux docker run
Browse files Browse the repository at this point in the history
Add cache mount directives to Linux docker container so that reruns
are much quicker.
  • Loading branch information
stevenh committed Mar 14, 2024
1 parent 6f3c983 commit 9c2cf45
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@
# -----------
FROM golang:1.21-alpine3.19 as build

# Go build env
ENV CGO_ENABLED=0

WORKDIR /app

# Go build env
ENV CGO_ENABLED=0 \
GOCACHE=/go-cache \
GOMODCACHE=/gomod-cache

# Install source deps
COPY go.mod go.sum ./
RUN go mod download
RUN --mount=type=cache,target=/gomod-cache \
go mod download

# Copy source & build
COPY . .
RUN go build -v -ldflags '-s' -o /bin/ryuk
RUN chmod +x /bin/ryuk
RUN --mount=type=cache,target=/gomod-cache \
--mount=type=cache,target=/go-cache \
go build -v -ldflags '-s' -o /bin/ryuk

# -----------------
# Distributed Image
Expand Down

0 comments on commit 9c2cf45

Please sign in to comment.