openapi-generator/docker-entrypoint.sh
Jim Schubert 436731184d [docker] Update root Dockerfile and run-in-docker
This update allows the root Dockerfile to be used as a development
container and updates run-in-docker.sh to use the same entrypoint script
while maintaining backward compatibility for anyone who has scripted
mappings to /gen and /root/.m2/repository.
2016-05-24 23:21:50 -04:00

25 lines
873 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# GEN_DIR allows to share the entrypoint between Dockerfile and run-in-docker.sh (backward compatible)
GEN_DIR=${GEN_DIR:-/opt/swagger-codegen}
JAVA_OPTS=${JAVA_OPTS:-"-Xmx1024M -DloggerPath=conf/log4j.properties"}
codegen="${GEN_DIR}/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
case "$1" in
generate|help|langs|meta|config-help)
# If ${GEN_DIR} has been mapped elsewhere from default, and that location has not been built
if [[ ! -f "${codegen}" ]]; then
(cd ${GEN_DIR} && exec mvn -am -pl "modules/swagger-codegen-cli" package)
fi
command=$1
shift
exec java ${JAVA_OPTS} -jar ${codegen} ${command} "$@"
;;
*) # Any other commands, e.g. docker run imagename ls -la or docker run -it imagename /bin/bash
exec "$@"
;;
esac