diff --git a/README.md b/README.md index 00f982f..ec708fc 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,7 @@ There are a bunch of environmental variables that can be set inside the docker c * `SIGNAL_CLI_GID`: Specifies the gid of the `signal-api` group inside the docker container. Defaults to `1000` +* `SWAGGER_IP`: The IP that's used in the Swagger UI for the interactive examples. Defaults to the container ip. ## Clients & Libraries diff --git a/entrypoint.sh b/entrypoint.sh index 8d9714e..a1c2601 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -29,5 +29,7 @@ service supervisor start supervisorctl start all fi +export HOST_IP=$(hostname -i) + # Start API as signal-api user exec setpriv --reuid=${SIGNAL_CLI_UID} --regid=${SIGNAL_CLI_GID} --init-groups --inh-caps=$caps signal-cli-rest-api -signal-cli-config=${SIGNAL_CLI_CONFIG_DIR} diff --git a/src/main.go b/src/main.go index ff02bd8..faf2098 100644 --- a/src/main.go +++ b/src/main.go @@ -69,6 +69,15 @@ func main() { router.Use(gin.Recovery()) + port := utils.GetEnv("PORT", "8080") + if _, err := strconv.Atoi(port); err != nil { + log.Fatal("Invalid PORT ", port, " set. PORT needs to be a number") + } + + defaultSwaggerIp := utils.GetEnv("HOST_IP", "127.0.0.1") + swaggerIp := utils.GetEnv("SWAGGER_IP", defaultSwaggerIp) + docs.SwaggerInfo.Host = swaggerIp + ":" + port + log.Info("Started Signal Messenger REST API") supportsSignalCliNative := "0" @@ -229,11 +238,6 @@ func main() { } } - port := utils.GetEnv("PORT", "8080") - if _, err := strconv.Atoi(port); err != nil { - log.Fatal("Invalid PORT ", port, " set. PORT needs to be a number") - } - swaggerUrl := ginSwagger.URL("http://127.0.0.1:" + string(port) + "/swagger/doc.json") router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, swaggerUrl))