From 2124d9af00714178f264e85b21f5af29f0f6de2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lie?= Date: Tue, 5 Mar 2024 10:25:55 +0100 Subject: [PATCH] add dockerfile, update libs --- dockerfile | 16 ++++++++++++++++ go.mod | 6 +++--- go.sum | 8 ++++---- server/server.go | 9 +++++---- 4 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 dockerfile diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..c702cdd --- /dev/null +++ b/dockerfile @@ -0,0 +1,16 @@ +FROM golang:1.22.0-alpine3.19 as build + +COPY src /src + +RUN cd /src \ + && go build -o retrohub \ + && mkdir -p ./fs/var/opt/retrohub \ + && mkdir -p ./fs/opt/retrohub \ + && cp retrohub ./fs/opt/retrohub/retrohub + +FROM scratch as prod + +COPY --from=build --chmod=755 /src/fs / + +EXPOSE 8080 +ENTRYPOINT [ "/opt/retrohub/retrohub", "-content", "/var/opt/retrohub/content.json" ] diff --git a/go.mod b/go.mod index 2776a29..7d3cb46 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module retroHub -go 1.20 +go 1.22 require ( - github.com/go-chi/chi/v5 v5.0.8 - github.com/mileusna/useragent v1.3.2 + github.com/go-chi/chi/v5 v5.0.12 + github.com/mileusna/useragent v1.3.4 ) diff --git a/go.sum b/go.sum index f008911..ad35c53 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,4 @@ -github.com/go-chi/chi/v5 v5.0.8 h1:lD+NLqFcAi1ovnVZpsnObHGW4xb4J8lNmoYVfECH1Y0= -github.com/go-chi/chi/v5 v5.0.8/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= -github.com/mileusna/useragent v1.3.2 h1:yGBQVNkyrlnSe4l0rlaQoH8XlG9xDkc6a7ygwPxALoU= -github.com/mileusna/useragent v1.3.2/go.mod h1:3d8TOmwL/5I8pJjyVDteHtgDGcefrFUX4ccGOMKNYYc= +github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s= +github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/mileusna/useragent v1.3.4 h1:MiuRRuvGjEie1+yZHO88UBYg8YBC/ddF6T7F56i3PCk= +github.com/mileusna/useragent v1.3.4/go.mod h1:3d8TOmwL/5I8pJjyVDteHtgDGcefrFUX4ccGOMKNYYc= diff --git a/server/server.go b/server/server.go index 1fdc88f..f0fe24f 100644 --- a/server/server.go +++ b/server/server.go @@ -5,15 +5,16 @@ import ( _ "embed" "errors" "fmt" - "github.com/go-chi/chi/v5" - "github.com/go-chi/chi/v5/middleware" - "github.com/mileusna/useragent" "html/template" "log" "net/http" "os" "retroHub/data" "strings" + + "github.com/go-chi/chi/v5" + "github.com/go-chi/chi/v5/middleware" + "github.com/mileusna/useragent" ) type injector struct { @@ -36,7 +37,7 @@ type errorInjector struct { StatusText string } -const version string = "0.1" +const version string = "0.1.1" //go:embed templates var templates embed.FS