Skip to content

Commit

Permalink
Merge pull request #142 from yubiuser/cache
Browse files Browse the repository at this point in the history
Introduce a separate dependency downloading step during docker build to cache dependencies for following runs
  • Loading branch information
yubiuser committed Jun 26, 2024
2 parents 5b261e2 + 10d3636 commit ed544e5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ updates:
open-pull-requests-limit: 10
target-branch: development
- package-ecosystem: gomod
directory: "/src/"
directory: "/"
schedule:
interval: weekly
day: sunday
Expand Down
18 changes: 11 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ARG alpine_version=3.20
ARG golang_version=1.22

FROM golang:${golang_version}-alpine${alpine_version} as builder
FROM golang:${golang_version}-alpine${alpine_version} AS builder
ARG GIT_COMMIT
ARG GIT_BRANCH
ARG GIT_VERSION
Expand All @@ -13,13 +13,17 @@ RUN apk add --no-cache \
git \
make

COPY /src /src
WORKDIR /src
# Download dependencies first to cache them
WORKDIR /app
COPY ./go.mod ./go.sum ./
RUN go mod download

# Copy the source code and build
COPY /src ./
RUN make build

FROM scratch as deploy
COPY --from=builder /src/docker-event-monitor docker-event-monitor
# the tls certificates:
# this pulls directly from the upstream image, which already has ca-certificates:
FROM scratch AS deploy
COPY --from=builder /app/docker-event-monitor docker-event-monitor
# this pulls directly from the upstream image, which already has ca-certificates
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
ENTRYPOINT ["/docker-event-monitor"]
File renamed without changes.
File renamed without changes.

0 comments on commit ed544e5

Please sign in to comment.