From ffa32ebd3afc01299f84c6aeeda7e8be3aec65a7 Mon Sep 17 00:00:00 2001 From: Robin Olsen Date: Wed, 18 Feb 2026 14:12:37 +0100 Subject: [PATCH] add dockerfile add make commands for building and running using docker remove localhost on server address so it's not locked --- Dockerfile | 12 ++++++++++++ Makefile | 6 ++++++ cmd/survey/init.go | 2 +- cmd/survey/tasks/createIssue.go | 2 +- pkg/web/server/server.go | 2 +- 5 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1b1571d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM golang:1.25.6-alpine AS builder +WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo \ + -ldflags="-w -s" -trimpath -o survey ./cmd/survey/ + +FROM gcr.io/distroless/static-debian13 +COPY --from=builder /app/survey /survey +EXPOSE 8080 +ENTRYPOINT ["/survey"] \ No newline at end of file diff --git a/Makefile b/Makefile index cd58e0e..2b51b88 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,12 @@ build: go build -o ./bin/tui ./cmd/tui go build -o ./bin/web ./cmd/web +docker-build: + @docker build -t survey . + +docker-run: + @docker run -it -p 8080:8080 survey:latest + cli: go run ./cmd/pm diff --git a/cmd/survey/init.go b/cmd/survey/init.go index 533976b..3ba29c1 100644 --- a/cmd/survey/init.go +++ b/cmd/survey/init.go @@ -16,7 +16,7 @@ func initializeServices(ctx context.Context) (*service.Services, func(), error) IssuePrefix: "pm", BeadsDBPath: "./.pm/db.db", StatisticsStoragePath: "./.pm/stats.json", - WebAddress: "localhost:8080", + WebAddress: ":8080", } return service.NewServices(ctx, config) } diff --git a/cmd/survey/tasks/createIssue.go b/cmd/survey/tasks/createIssue.go index 9a9a2d4..79ac42b 100644 --- a/cmd/survey/tasks/createIssue.go +++ b/cmd/survey/tasks/createIssue.go @@ -27,7 +27,7 @@ func createIssueConfig() task.TaskConfig { IssuePrefix: "pm", BeadsDBPath: "./.pm/db.db", StatisticsStoragePath: "./.pm/task-1-stats.json", - WebAddress: "localhost:8080", + WebAddress: ":8080", } } diff --git a/pkg/web/server/server.go b/pkg/web/server/server.go index 9a5553b..da06a1b 100644 --- a/pkg/web/server/server.go +++ b/pkg/web/server/server.go @@ -17,7 +17,7 @@ type Server struct { // NewServer creates and configures a new HTTP server instance. func NewServer(props Server) *http.Server { if props.Address == "" { - props.Address = "localhost:8080" + props.Address = ":8080" } handler := props.RegisterRoutes(props.Assets)