[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.
This commit is contained in:
Jim Schubert 2019-07-07 10:25:43 -04:00 committed by GitHub
parent 366ca24062
commit 51e7005373
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.