openapi-generator/.hub.online.dockerfile
Jim Schubert 51e7005373
[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.
2019-07-07 10:25:43 -04:00

36 lines
974 B
Docker

## The builder labeled image acts as a transient container which is meant to
## hold all non-artifact code.
##
## You can build _just_ this part with:
## docker --target builder -t container-name:builder -f .hub.online.dockerfile .
FROM jimschubert/8-jdk-alpine-mvn:1.0 as builder
RUN set -x && \
apk add --no-cache bash
ENV GEN_DIR /opt/openapi-generator
WORKDIR ${GEN_DIR}
COPY . ${GEN_DIR}
# Pre-compile openapi-generator-online
RUN mvn -am -pl "modules/openapi-generator-online" package
## The final (release) image
## The resulting container here only needs the target jar
FROM openjdk:8-jre-alpine
ENV GEN_DIR /opt/openapi-generator
ENV TARGET_DIR /generator
RUN mkdir -p ${TARGET_DIR}
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=""
EXPOSE 8080
CMD ["java", "-jar", "/generator/openapi-generator-online.jar"]