From 04555e4805db425446dcfe76380ce36a1c2ffdf6 Mon Sep 17 00:00:00 2001 From: Christopher Bross Date: Tue, 21 Jul 2020 14:48:14 +0200 Subject: [PATCH] =?UTF-8?q?add=20Dokerfile=20und=20anpassungen=20um=20es?= =?UTF-8?q?=20im=20container=20ausf=C3=BChren=20k=C3=B6n=20k=C3=B6nnen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 36 +++++++++++++++++++++++++++++++++++ backend/go/src/server/main.go | 3 ++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..217e799 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +FROM golang:alpine as builder + +RUN apk --no-cache add --update \ + gcc \ + musl-dev \ + git \ + ca-certificates +WORKDIR /go/src/gitea.ckris.de/titzi/anmeldeportal_hochzeit +RUN CGO_ENABLED=1 go get -d -v github.com/mattn/go-sqlite3 +COPY backend/go/src/server/main.go . +RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o backend . + + + +FROM alpine:latest + +RUN apk --no-cache add --update \ + gcc \ + musl-dev + +WORKDIR /go/ + +COPY --from=builder /go/src/gitea.ckris.de/titzi/anmeldeportal_hochzeit/backend . +COPY frontend/assets ./frontend/assets/ +COPY frontend/js ./frontend/js/ +COPY frontend/css ./frontend/css/ +COPY frontend/index.html ./frontend/ + +RUN addgroup -g 3333 -S go && \ + adduser -h /go -u 3333 -G go -S go && \ + chown -R go:go . +USER go + +EXPOSE 8080 + +CMD ["./backend"] \ No newline at end of file diff --git a/backend/go/src/server/main.go b/backend/go/src/server/main.go index fca6c78..74b375f 100644 --- a/backend/go/src/server/main.go +++ b/backend/go/src/server/main.go @@ -102,7 +102,8 @@ func main() { defer db.Close() // init http server with two routes for onepage website and endpoint for sending the response - http.Handle("/", httpLogHandler(http.FileServer(http.Dir("../../../../frontend")))) + // http.Handle("/", httpLogHandler(http.FileServer(http.Dir("../../../../frontend")))) + http.Handle("/", httpLogHandler(http.FileServer(http.Dir("./frontend")))) http.HandleFunc("/response", func(w http.ResponseWriter, r *http.Request) { processAnmeldung(w, r, db) })