-
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.
Merge pull request #6 from rorycl/web-docker
v0.2.4: improve error handling; deploy via docker
- Loading branch information
Showing
6 changed files
with
51 additions
and
10 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 |
---|---|---|
|
@@ -9,3 +9,4 @@ go.work | |
cover.html | ||
cover.rpt | ||
coverage.out | ||
deploy |
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,28 @@ | ||
# build the webapp including dependencies from / and /cmd | ||
|
||
FROM golang:1.22 AS deps | ||
|
||
# setup module environment | ||
WORKDIR /build | ||
ADD *mod ./ | ||
ADD *sum ./ | ||
RUN go mod download | ||
ADD cmd/web/*mod ./cmd/web/ | ||
ADD cmd/web/*sum ./cmd/web/ | ||
RUN cd /build/cmd/web && go mod download | ||
|
||
# build | ||
FROM deps as dev | ||
ADD *go ./ | ||
ADD cmd/*go ./cmd/ | ||
ADD cmd/web/ ./cmd/web/ | ||
RUN cd cmd/web && \ | ||
CGO_ENABLED=0 GOOS=linux \ | ||
go build -ldflags "-w -X main.docker=true" -o /build/webserver . | ||
|
||
# install into minimal image | ||
FROM gcr.io/distroless/base AS base | ||
WORKDIR / | ||
EXPOSE 8000 | ||
COPY --from=dev /build/webserver / | ||
CMD ["/webserver", "--address", "0.0.0.0", "--port", "8000"] |
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
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
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
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