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
WORKDIR /app
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 ./news ./news
COPY ./public ./public
COPY ./.env ./.env
EXPOSE 8000
CMD ["./website-server"]

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

@ -3,6 +3,7 @@ package main
import (
"fmt"
"html/template"
"log"
"time"
"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