diff --git a/docker-compose.yml b/docker-compose.yml index ae170a6..907c55b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,8 +6,8 @@ services: options: max-size: "200k" max-file: "10" - image: jffrancob/wa-multidevice:0.0.3 - command: --os=Linux --debug true --basic-auth=admin:password + image: jffrancob/wa-multidevice:0.0.4 + command: --os=Linux --debug true environment: - SERVER_URL=http://${API_HOST-localhost}:${API_PORT-3000} working_dir: /whatsapp diff --git a/docker/golang.Dockerfile b/docker/golang.Dockerfile index aed580f..480cdbc 100644 --- a/docker/golang.Dockerfile +++ b/docker/golang.Dockerfile @@ -1,14 +1,13 @@ ############################ # STEP 1 build executable binary ############################ -FROM golang:1.20.5-alpine3.17 AS builder +FROM golang:1.21.3-alpine3.18 AS builder RUN apk update && apk add --no-cache vips-dev gcc musl-dev gcompat ffmpeg WORKDIR /whatsapp COPY ./src . # Fetch dependencies. RUN go mod download -#RUN go mod tidy -e # Install pkger RUN go install github.com/markbates/pkger/cmd/pkger@latest # Build the binary. @@ -16,22 +15,23 @@ RUN pkger RUN go build -o /app/whatsapp -#FROM builder AS dev -#RUN go install github.com/cosmtrek/air@latest -#RUN go mod tidy -#RUN go mod download +FROM builder AS dev +RUN go install github.com/cosmtrek/air@latest +RUN go mod tidy +RUN go mod download +RUN go mod tidy -e -#CMD ["air", "-c", ".air.toml"] +CMD ["air", "-c", ".air.toml"] ############################# ## STEP 2 build a smaller image ############################# -FROM alpine:3.17 as runtime +FROM alpine:3.18 as runtime RUN apk update && apk add --no-cache vips ffmpeg COPY ./docs /docs WORKDIR /app # Copy compiled from builder. COPY --from=builder /app/whatsapp /app/whatsapp # Run the binary. -ENTRYPOINT ["/app/whatsapp"] \ No newline at end of file +ENTRYPOINT ["/app/whatsapp"] diff --git a/src/cmd/root.go b/src/cmd/root.go index b7f4079..c8644fc 100644 --- a/src/cmd/root.go +++ b/src/cmd/root.go @@ -128,13 +128,13 @@ func runRest(_ *cobra.Command, _ []string) { {"url": string(serverURL)}, } return c.Render("doc", fiber.Map{ - "AppHost": fmt.Sprintf("%s://%s", c.Protocol(), c.Hostname()), + "AppHost": fmt.Sprintf("%s", c.BaseURL()), "Spec": toJSON(spec), "BasicAuthToken": c.UserContext().Value("token"), }) } else { return c.Render("index", fiber.Map{ - "AppHost": fmt.Sprintf("%s://%s", c.Protocol(), c.Hostname()), + "AppHost": fmt.Sprintf("%s", c.BaseURL()), "AppVersion": config.AppVersion, "BasicAuthToken": c.UserContext().Value("token"), "MaxFileSize": humanize.Bytes(uint64(config.WhatsappSettingMaxFileSize)), diff --git a/src/internal/rest/app.go b/src/internal/rest/app.go index 19775d4..8ddfdbb 100644 --- a/src/internal/rest/app.go +++ b/src/internal/rest/app.go @@ -30,8 +30,8 @@ func (handler *App) Login(c *fiber.Ctx) error { Code: "SUCCESS", Message: "Login success", Results: map[string]any{ - "qr_link": fmt.Sprintf("%s://%s/%s", c.Protocol(), c.Hostname(), response.ImagePath), - "qr_duration": response.Duration, + "qr_link": fmt.Sprintf("%s%s/%s", c.BaseURL(), c.Get("X-Forwarded-Prefix"), response.ImagePath), + "qr_duration": response.Duration, }, }) }