Skip to content

Commit 51e7005

Browse files
authored
[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.
1 parent 366ca24 commit 51e7005

5 files changed

Lines changed: 12 additions & 9 deletions

File tree

.hub.online.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ WORKDIR ${TARGET_DIR}
2828

2929
COPY --from=builder ${GEN_DIR}/modules/openapi-generator-online/target/openapi-generator-online.jar ${TARGET_DIR}/openapi-generator-online.jar
3030

31-
ENV GENERATOR_HOST=http://localhost
31+
ENV GENERATOR_HOST=""
3232

3333
EXPOSE 8080
3434

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ Example usage:
281281

282282
```sh
283283
# Start container at port 8888 and save the container id
284-
> CID=$(docker run -d -p 8888:8080 -e GENERATOR_HOST=http://localhost:8888 openapitools/openapi-generator-online)
284+
> CID=$(docker run -d -p 8888:8080 openapitools/openapi-generator-online)
285285

286286
# allow for startup
287287
> sleep 10

docs/online.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ Example usage:
2323

2424
```bash
2525
# Start container at port 8888 and save the container id
26-
CID=$(docker run -d -p 8888:8080 \
27-
-e GENERATOR_HOST=http://localhost:8888 \
28-
openapitools/openapi-generator-online)
26+
CID=$(docker run -d -p 8888:8080 openapitools/openapi-generator-online)
2927

3028
# allow for startup
3129
sleep 10

modules/openapi-generator-online/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ COPY target/openapi-generator-online.jar /generator/openapi-generator-online.jar
66

77
# GENERATOR_HOST can be used to determine the target location of a download link.
88
# The default value asumes binding to host via: docker -p 8080:8080 image_name
9-
ENV GENERATOR_HOST=http://localhost:8080
9+
# Generally, this "just works" without GENERATOR_HOST, and this is provided only as
10+
# a workaround if all else fails.
11+
ENV GENERATOR_HOST=""
1012

1113
EXPOSE 8080
1214

modules/openapi-generator-online/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ docker build -t openapitools/openapi-generator-online:latest .
4646
Now, run the docker image:
4747

4848
```
49-
docker run -d -p 8888:8080 \
50-
-e GENERATOR_HOST=http://localhost:8888 \
51-
openapitools/openapi-generator-online
49+
docker run -d -p 8888:8080 openapitools/openapi-generator-online
5250
```
5351

5452
The `GENERATOR_HOST` variable is used here to ensure download links generated by the API refer to the proper API location.
53+
54+
## Environment
55+
56+
`GENERATOR_HOST` can be set to force the scheme/host/port used for download link generation. In most cases, this environment variable is not
57+
necessary to be set and the download link will be generated to match the originating request. The variable is provided simply as a fallback.

0 commit comments

Comments
 (0)