Skip to content

Commit

Permalink
dockerfile for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
will-wow committed May 26, 2024
1 parent 3e30e11 commit 5753a5e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
18 changes: 18 additions & 0 deletions examples/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM --platform=$BUILDPLATFORM golang:alpine as builder
WORKDIR /go/src/app

RUN apk add git

COPY go.mod go.sum ./
RUN go mod download

COPY . .

ARG TARGETOS TARGETARCH
# Static build required so that we can safely copy the binary over.
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o ./bin/server -ldflags '-extldflags "-static"' ./cmd/server/main.go

FROM scratch
COPY --from=builder /go/src/app/bin/server /server
EXPOSE 8080
ENTRYPOINT ["/server"]
5 changes: 5 additions & 0 deletions examples/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,8 @@ tasks:
desc: Install tools
cmds:
- go install github.com/a-h/templ/cmd/templ@latest

push:
desc: Push to docker hub
cmds:
- docker buildx build --platform linux/arm64 -t willwow/thxgo:latest --push .
2 changes: 1 addition & 1 deletion examples/cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func main() {

//nolint:exhaustruct
server := &http.Server{
Addr: "localhost:8080",
Addr: ":8080",
Handler: handler,
ReadTimeout: time.Second * 10,
WriteTimeout: time.Second * 10,
Expand Down

0 comments on commit 5753a5e

Please sign in to comment.