Dockerfile corrected. Build failures

This commit is contained in:
2022-01-04 21:48:57 +01:00
parent 65e884e3cb
commit 58fac0aa1e
2 changed files with 11 additions and 3 deletions

View File

@@ -5,13 +5,16 @@ WORKDIR ui
RUN npm install && ng build --prod RUN npm install && ng build --prod
FROM golang:1.17.5 AS GO_BUILD FROM golang:alpine AS GO_BUILD
COPY ./ /server COPY ./ /server
WORKDIR /server WORKDIR /server
ADD go.mod .
ADd go.sum .
RUN go mod download
RUN go build -o /go/bin/server RUN go build -o /go/bin/server
FROM alpine:3.15 FROM alpine:3.15
WORKDIR app WORKDIR app
COPY --from=ANGULAR_BUILD /ui/dist/ui/* ./ui/dist/ui/ COPY --from=ANGULAR_BUILD /ui/dist/ui/* ./ui/dist/ui/
COPY --from=GO_BUILD /go/bin/server ./ COPY --from=GO_BUILD /go/bin/server ./
CMD /app/server CMD ./server

View File

@@ -1,6 +1,7 @@
package main package main
import ( import (
"fmt"
"path" "path"
"path/filepath" "path/filepath"
@@ -15,6 +16,7 @@ var (
func main() { func main() {
//setAuth0Variables() //setAuth0Variables()
fmt.Println("Hallo")
r := gin.Default() r := gin.Default()
r.Use(CORSMiddleware()) r.Use(CORSMiddleware())
r.NoRoute((func(c *gin.Context) { r.NoRoute((func(c *gin.Context) {
@@ -26,6 +28,7 @@ func main() {
c.File("./ui/dist/ui/" + path.Join(dir, file)) c.File("./ui/dist/ui/" + path.Join(dir, file))
} }
})) }))
//authorized := r.Group("/") //authorized := r.Group("/")
//authorized.Use(authRequired()) //authorized.Use(authRequired())
@@ -40,6 +43,7 @@ func main() {
} }
} }
func CORSMiddleware() gin.HandlerFunc { func CORSMiddleware() gin.HandlerFunc {
return func(c *gin.Context) { return func(c *gin.Context) {
c.Writer.Header().Set("Access-Control-Allow-Origin", "*") c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
@@ -75,9 +79,10 @@ func authRequired() gin.HandlerFunc {
c.Next() c.Next()
} }
} }
*/
*/
func terminateWithError(statusCode int, message string, c *gin.Context) { func terminateWithError(statusCode int, message string, c *gin.Context) {
c.JSON(statusCode, gin.H{"error": message}) c.JSON(statusCode, gin.H{"error": message})
c.Abort() c.Abort()
} }