This repository has been archived by the owner on Apr 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2eae5f
commit 4353a8d
Showing
2 changed files
with
32 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
**/.dockerignore | ||
**/.github | ||
**/.gitignore | ||
**/.vscode | ||
**/compose* | ||
**/Dockerfile* | ||
LICENSE | ||
README.md | ||
todoapp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
FROM cgr.dev/chainguard/go:latest as builder | ||
# syntax=docker/dockerfile:1 | ||
|
||
WORKDIR /app | ||
COPY . . | ||
RUN CGO_ENABLED=0 go build -o todoapp ./cmd/todoapp | ||
FROM cgr.dev/chainguard/go:latest as build | ||
|
||
WORKDIR /src | ||
|
||
# Download dependencies as a separate step to take advantage of Docker's caching. | ||
# Leverage a cache mount to /go/pkg/mod/ to speed up subsequent builds. | ||
# Leverage bind mounts to go.sum and go.mod to avoid having to copy them into | ||
# the container. | ||
RUN --mount=type=cache,target=/go/pkg/mod/ \ | ||
--mount=type=bind,source=go.sum,target=go.sum \ | ||
--mount=type=bind,source=go.mod,target=go.mod \ | ||
go mod download -x | ||
|
||
# Build the application. | ||
# Leverage a cache mount to /go/pkg/mod/ to speed up subsequent builds. | ||
# Leverage a bind mount to the current directory to avoid having to copy the | ||
# source code into the container. | ||
RUN --mount=type=cache,target=/go/pkg/mod/ \ | ||
--mount=type=bind,target=. \ | ||
CGO_ENABLED=0 go build -o /bin/server ./cmd/todoapp | ||
|
||
FROM cgr.dev/chainguard/static:latest | ||
|
||
COPY --from=build /bin/server /bin/ | ||
EXPOSE 8080 | ||
COPY --from=builder /app/todoapp /todoapp | ||
|
||
ENTRYPOINT ["/todoapp"] | ||
ENTRYPOINT [ "/bin/server" ] |