cleanup for the docker setup

Signed-off-by: ngn <ngn@ngn.tf>
This commit is contained in:
ngn
2025-01-18 03:31:37 +03:00
parent ecaa6fb68f
commit fa2f3acb35
34 changed files with 433 additions and 319 deletions

View File

@ -2,9 +2,16 @@ FROM golang:1.23.4
WORKDIR /api
COPY *.go ./
RUN useradd runner -r -u 1001 -d /api
RUN chown -R runner:runner /api
USER runner
COPY *.mod ./
COPY *.sum ./
RUN go mod download
COPY *.go ./
COPY Makefile ./
COPY config ./config
COPY database ./database
@ -14,7 +21,6 @@ COPY status ./status
COPY util ./util
COPY views ./views
EXPOSE 7001
RUN make
ENTRYPOINT ["/api/api.elf"]

View File

@ -6,7 +6,7 @@ api.elf: $(GOSRCS)
go build -o $@
run:
API_DEBUG=true API_APP_URL=http://localhost:7002 API_PASSWORD=test ./api.elf
WEBSITE_DEBUG=true WEBSITE_PASSWORD=test ./api.elf
format:
gofmt -s -w .

View File

@ -39,12 +39,11 @@ func (c *Type) Load() (err error) {
c.Options = []Option{
{Name: "debug", Value: "false", Type: OPTION_TYPE_BOOL, Required: true}, // should display debug messgaes?
{Name: "url", Value: "http://localhost:7001/", Type: OPTION_TYPE_URL, Required: true}, // API URL for the website
{Name: "app_url", Value: "http://localhost:7002/", Type: OPTION_TYPE_URL, Required: true}, // frontend application URL for the website
{Name: "doc_url", Value: "http://localhost:7003/", Type: OPTION_TYPE_URL, Required: true}, // documentation URL for the website
{Name: "app_url", Value: "http://localhost:7001/", Type: OPTION_TYPE_URL, Required: true}, // frontend application URL for the website
{Name: "api_url", Value: "http://localhost:7002/", Type: OPTION_TYPE_URL, Required: true}, // API URL for the website
{Name: "password", Value: "", Type: OPTION_TYPE_STR, Required: true}, // admin password
{Name: "host", Value: "0.0.0.0:7001", Type: OPTION_TYPE_STR, Required: true}, // host the server should listen on
{Name: "host", Value: "0.0.0.0:7002", Type: OPTION_TYPE_STR, Required: true}, // host the server should listen on
{Name: "ip_header", Value: "X-Real-IP", Type: OPTION_TYPE_STR, Required: false}, // header that should be checked for obtaining the client IP
{Name: "interval", Value: "1h", Type: OPTION_TYPE_STR, Required: false}, // service status check interval
{Name: "timeout", Value: "15s", Type: OPTION_TYPE_STR, Required: false}, // timeout for the service status check

View File

@ -25,7 +25,7 @@ type Option struct {
}
func (o *Option) Env() string {
return strings.ToUpper(fmt.Sprintf("API_%s", o.Name))
return strings.ToUpper(fmt.Sprintf("WEBSITE_%s", o.Name))
}
func (o *Option) Load() (err error) {

View File

@ -7,7 +7,8 @@ import (
func GET_Index(c *fiber.Ctx) error {
conf := c.Locals("config").(*config.Type)
doc := conf.GetURL("doc_url")
app := conf.GetURL("app_url")
return c.Redirect(doc.JoinPath("/api").String())
// redirect to the API documentation
return c.Redirect(app.JoinPath("/doc/api").String())
}