Fixed dockerfile

main-old
Antonio De Lucreziis 2 years ago
parent cb76d0cdf2
commit 45d41d714b

@ -0,0 +1,3 @@
Dockerfile
node_modules
.git

@ -16,9 +16,10 @@ RUN go build -buildvcs=false -o website-server -v .
FROM alpine:latest AS runner FROM alpine:latest AS runner
WORKDIR /app WORKDIR /app
COPY --from=frontend-builder /frontend/dist ./frontend/dist COPY --from=frontend-builder /frontend/dist ./frontend/dist
COPY --from=backend-builder / ./website-server COPY --from=backend-builder /backend/website-server ./website-server
COPY ./views ./views COPY ./views ./views
COPY ./news ./news COPY ./news ./news
COPY ./public ./public COPY ./public ./public
COPY ./.env ./.env
EXPOSE 8000 EXPOSE 8000
CMD ["./website-server"] CMD ["./website-server"]

@ -27,16 +27,20 @@ func loadEnv(target *string, name, defaultValue string) {
} else { } else {
*target = value *target = value
} }
log.Printf("%s = %v", name, *target) log.Printf("%s = %v", name, *target)
} }
func Load() { func Load() {
godotenv.Load() if err := godotenv.Load(); err != nil {
panic(err)
}
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile) log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
// Production // Production
loadEnv(&Mode, "MODE", "production") loadEnv(&Mode, "MODE", "production")
loadEnv(&Host, "HOST", "localhost:8080") loadEnv(&Host, "HOST", ":8080")
// Services // Services
loadEnv(&GitUrl, "GIT_URL", "https://git.example.org") loadEnv(&GitUrl, "GIT_URL", "https://git.example.org")

@ -3,6 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"html/template" "html/template"
"log"
"time" "time"
"git.phc.dm.unipi.it/phc/website/articles" "git.phc.dm.unipi.it/phc/website/articles"
@ -198,5 +199,9 @@ func main() {
}) })
}) })
app.Listen(config.Host) log.Printf("Starting server on host %q", config.Host)
err := app.Listen(config.Host)
if err != nil {
log.Fatal(err)
}
} }

Loading…
Cancel
Save