Skip to content

Commit 200ae36

Browse files
committed
feat: add Dockerfile
1 parent 20699e1 commit 200ae36

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM golang:1.22.1-alpine AS build-stage
2+
3+
WORKDIR /app
4+
5+
COPY go.mod go.sum ./
6+
RUN go mod download
7+
8+
COPY . ./
9+
10+
RUN CGO_ENABLED=0 GOOS=linux go build -tags netgo -ldflags '-s -w' -o /server
11+
12+
FROM gcr.io/distroless/base-debian11 AS build-release-stage
13+
14+
WORKDIR /
15+
16+
COPY --from=build-stage /server /server
17+
COPY --from=build-stage /app/templates /templates
18+
COPY --from=build-stage /app/static /static
19+
20+
EXPOSE 8080
21+
22+
USER nonroot:nonroot
23+
24+
ENTRYPOINT ["/server"]

main.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ func run(ctx context.Context) error {
2525
ctx, cancel := signal.NotifyContext(ctx, os.Interrupt, syscall.SIGTERM)
2626
defer cancel()
2727

28-
err := godotenv.Load()
29-
if err != nil {
30-
log.Fatal("Error loading .env file")
31-
}
28+
godotenv.Load()
3229

3330
oauth2Conf := &oauth2.Config{
3431
ClientID: os.Getenv("GH_CLIENT_ID"),

0 commit comments

Comments
 (0)