From cb8f59f304bfeafff771a05934698caaf128e871 Mon Sep 17 00:00:00 2001 From: Garrett Ladley <92384606+garrettladley@users.noreply.github.com> Date: Tue, 11 Jun 2024 17:24:46 -0400 Subject: [PATCH] Dockerfile.server fixes (#1003) --- backend/.dockerignore | 1 - backend/Dockerfile.server | 17 ++++++++--------- backend/main.go | 2 ++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/.dockerignore b/backend/.dockerignore index 9ffcea7d..97ae4a9c 100644 --- a/backend/.dockerignore +++ b/backend/.dockerignore @@ -1,4 +1,3 @@ tests/ -docs/ *.md *.templ \ No newline at end of file diff --git a/backend/Dockerfile.server b/backend/Dockerfile.server index 57044ccc..9050bb44 100644 --- a/backend/Dockerfile.server +++ b/backend/Dockerfile.server @@ -1,18 +1,17 @@ FROM golang:1.22-alpine as builder WORKDIR /app -RUN apk add --no-cache git -COPY . ./ -RUN go install github.com/a-h/templ/cmd/templ@latest -RUN templ generate -RUN go get ./... -RUN go mod tidy +COPY . . + RUN go mod download -RUN go build -tags prod -o bin/sac main.go -FROM scratch +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o bin/sac main.go + +FROM alpine:latest as release + COPY --from=builder /app/bin/sac /sac EXPOSE 8080 -ENTRYPOINT [ "./sac" ] \ No newline at end of file + +ENTRYPOINT [ "/sac" ] \ No newline at end of file diff --git a/backend/main.go b/backend/main.go index aea4c560..42b89e14 100644 --- a/backend/main.go +++ b/backend/main.go @@ -18,6 +18,8 @@ import ( "github.com/GenerateNU/sac/backend/constants" "github.com/GenerateNU/sac/backend/database" "github.com/GenerateNU/sac/backend/database/store" + + // TODO: disable for prod with build tag _ "github.com/GenerateNU/sac/backend/docs" "github.com/GenerateNU/sac/backend/integrations" "github.com/GenerateNU/sac/backend/integrations/email"