diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bdfd329 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM golang:alpine3.13 as builder + +RUN apk update && apk upgrade && \ + apk --no-cache --update add git make + +WORKDIR /go/src/github.com/Aldiwildan77/rust-updater + +COPY . . + +RUN go mod download && \ + go build -v -o engine && \ + chmod +x engine + +## Distribution +FROM alpine:latest + +RUN apk update && apk upgrade && \ + apk --no-cache --update add ca-certificates tzdata && \ + mkdir /app && mkdir rust-updater + +WORKDIR /rust-updater + +EXPOSE 8000 + +COPY --from=builder /go/src/github.com/Aldiwildan77/rust-updater/engine /app + +CMD /app/engine diff --git a/README.md b/README.md index 7a3a644..418ff0f 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,16 @@ This repository is for update notifications from the rust game which helps server admins to get official game updates ## How to build +### Native build: 1. Please check your current OS and Architecture, run `go env`. 2. Build this project using command `env GOOS= GOARCH= go build -v -o bin/api`. 3. Give output permission to execute. 4. Run the server, depending on your operating system. -> Next update will be support for docker +### Docker build: +1. Make sure you have installed docker on your machine. +2. Build the project using command `docker build . ` +3. Start the project using command `docker run -h localhost -p 8000:8000 -e PORT=8000 rust-updater-api_app:latest` ## Contact If you need more information please join the discord: https://discord.chroma-gaming.xyz/ diff --git a/api/gateways/routes/route.go b/api/gateways/routes/route.go index b654438..909511a 100644 --- a/api/gateways/routes/route.go +++ b/api/gateways/routes/route.go @@ -23,5 +23,5 @@ func (ur *Route) Init(e *echo.Echo) { g := e.Group("/api") r := g.Group("/notifier") - r.GET("/", ur.Handler.GetUpdater) + r.GET("", ur.Handler.GetUpdater) } diff --git a/routes/route.go b/routes/route.go index c9343bc..e72e86e 100644 --- a/routes/route.go +++ b/routes/route.go @@ -6,9 +6,12 @@ import ( "github.com/Aldiwildan77/rust-notifier-api/api" "github.com/Aldiwildan77/rust-notifier-api/api/gateways/routes" "github.com/labstack/echo/v4" + "github.com/labstack/echo/v4/middleware" ) func Register(e *echo.Echo) { + e.Pre(middleware.RemoveTrailingSlash()) + e.GET("/health", func(c echo.Context) error { return c.String(http.StatusOK, "Iam fine thanks") })