From 51e7005373fdb55daa1c253f36fb6267a64a7bf7 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sun, 7 Jul 2019 10:25:43 -0400 Subject: [PATCH] [online] Remove GENERATOR_HOST defaults (#3289) The defaults configured for GENERATOR_HOST didn't really make sense. When running the docker container with `-P`, GENERATOR_HOST defaulted to http://localhost. This caused download links for generated client/server code to be incorrect. For most cases, there's no reason to provide GENERATOR_HOST as the code already figures the appropriate scheme/host/port from the originating request. GENERATOR_HOST could still be used for more complex deployment scenarios, for instance if a specific server is configured as a file server. I haven't tested this scenario, and it may require mounting /tmp as a volume when running within a container. --- .hub.online.dockerfile | 2 +- README.md | 2 +- docs/online.md | 4 +--- modules/openapi-generator-online/Dockerfile | 4 +++- modules/openapi-generator-online/README.md | 9 ++++++--- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.hub.online.dockerfile b/.hub.online.dockerfile index 083b84d4ead..6992dff0509 100644 --- a/.hub.online.dockerfile +++ b/.hub.online.dockerfile @@ -28,7 +28,7 @@ WORKDIR ${TARGET_DIR} COPY --from=builder ${GEN_DIR}/modules/openapi-generator-online/target/openapi-generator-online.jar ${TARGET_DIR}/openapi-generator-online.jar -ENV GENERATOR_HOST=http://localhost +ENV GENERATOR_HOST="" EXPOSE 8080 diff --git a/README.md b/README.md index 6adf7b2c58f..9106b6d5653 100644 --- a/README.md +++ b/README.md @@ -281,7 +281,7 @@ Example usage: ```sh # Start container at port 8888 and save the container id -> CID=$(docker run -d -p 8888:8080 -e GENERATOR_HOST=http://localhost:8888 openapitools/openapi-generator-online) +> CID=$(docker run -d -p 8888:8080 openapitools/openapi-generator-online) # allow for startup > sleep 10 diff --git a/docs/online.md b/docs/online.md index 417b4099f7d..9ae4eb9853a 100644 --- a/docs/online.md +++ b/docs/online.md @@ -23,9 +23,7 @@ Example usage: ```bash # Start container at port 8888 and save the container id -CID=$(docker run -d -p 8888:8080 \ - -e GENERATOR_HOST=http://localhost:8888 \ - openapitools/openapi-generator-online) +CID=$(docker run -d -p 8888:8080 openapitools/openapi-generator-online) # allow for startup sleep 10 diff --git a/modules/openapi-generator-online/Dockerfile b/modules/openapi-generator-online/Dockerfile index 71e238dbb5e..ae0de1cc2e2 100644 --- a/modules/openapi-generator-online/Dockerfile +++ b/modules/openapi-generator-online/Dockerfile @@ -6,7 +6,9 @@ COPY target/openapi-generator-online.jar /generator/openapi-generator-online.jar # GENERATOR_HOST can be used to determine the target location of a download link. # The default value asumes binding to host via: docker -p 8080:8080 image_name -ENV GENERATOR_HOST=http://localhost:8080 +# Generally, this "just works" without GENERATOR_HOST, and this is provided only as +# a workaround if all else fails. +ENV GENERATOR_HOST="" EXPOSE 8080 diff --git a/modules/openapi-generator-online/README.md b/modules/openapi-generator-online/README.md index b3c5ffc244f..2c77fa3c69c 100644 --- a/modules/openapi-generator-online/README.md +++ b/modules/openapi-generator-online/README.md @@ -46,9 +46,12 @@ docker build -t openapitools/openapi-generator-online:latest . Now, run the docker image: ``` -docker run -d -p 8888:8080 \ - -e GENERATOR_HOST=http://localhost:8888 \ - openapitools/openapi-generator-online +docker run -d -p 8888:8080 openapitools/openapi-generator-online ``` The `GENERATOR_HOST` variable is used here to ensure download links generated by the API refer to the proper API location. + +## Environment + +`GENERATOR_HOST` can be set to force the scheme/host/port used for download link generation. In most cases, this environment variable is not +necessary to be set and the download link will be generated to match the originating request. The variable is provided simply as a fallback. \ No newline at end of file