From 1da350e8197a0f27fdea7b158a85a7bfe0dbef7b Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Mon, 23 May 2016 21:54:35 -0400 Subject: [PATCH] [docker] Cleanup and reduce container sizes --- .dockerignore | 39 +++++++--------------------- Dockerfile | 15 ++++++----- modules/swagger-generator/Dockerfile | 5 ++-- 3 files changed, 21 insertions(+), 38 deletions(-) diff --git a/.dockerignore b/.dockerignore index 75ea5de6ca..664eefdb4e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ +.git/ *.iml out/ *.ipr @@ -13,35 +14,13 @@ generated-sources/* generated-code/* *.swp *.swo - -/target -/generated-files -/nbactions.xml -*.pyc -__pycache__ -samples/server-generator/scalatra/output -samples/server-generator/node/output/node_modules -samples/server-generator/scalatra/target -samples/server-generator/scalatra/output/.history -samples/client/petstore/qt5cpp/PetStore/moc_* -samples/client/petstore/qt5cpp/PetStore/*.o -samples/client/petstore/objc/PetstoreClient.xcworkspace/xcuserdata -samples/client/petstore/qt5cpp/build-* -samples/client/petstore/qt5cpp/PetStore/PetStore -samples/client/petstore/qt5cpp/PetStore/Makefile -samples/client/petstore/java/hello.txt -samples/client/petstore/android/default/hello.txt -samples/client/petstore/objc/Build -samples/client/petstore/objc/Pods -samples/server/petstore/nodejs/node_modules -target -.idea -.lib -atlassian-ide-plugin.xml +*.bak +project/ +samples/* +target/ +.idea/ +.lib/ .DS_Store -samples/client/petstore/php/SwaggerClient-php/composer.lock -samples/client/petstore/php/SwaggerClient-php/vendor/ - -samples/client/petstore/silex/SwaggerServer/composer.lock -samples/client/petstore/silex/SwaggerServer/venodr/ +# Not needed in a linux container +bin/windows/* diff --git a/Dockerfile b/Dockerfile index 0a3d093290..0a67e79e3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,16 @@ -FROM maven:3.3-jdk-7 +FROM jimschubert/8-jdk-alpine-mvn -WORKDIR /src -VOLUME /src -VOLUME /root/.m2/repository +RUN mkdir /opt ADD . /opt/swagger-codegen -RUN cd /opt/swagger-codegen && mvn package +WORKDIR /opt/swagger-codegen -ENTRYPOINT ["java", "-jar", "/opt/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"] +RUN mvn -am -pl "modules/swagger-codegen-cli" package && \ + mv /opt/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar /opt/swagger-codegen/swagger-codegen-cli.jar && \ + mvn clean && \ + rm -rf ${MAVEN_HOME}/.m2/repository + +ENTRYPOINT ["java", "-jar", "/opt/swagger-codegen/swagger-codegen-cli.jar"] CMD ["help"] diff --git a/modules/swagger-generator/Dockerfile b/modules/swagger-generator/Dockerfile index dc31cbd965..6ff3793311 100644 --- a/modules/swagger-generator/Dockerfile +++ b/modules/swagger-generator/Dockerfile @@ -1,12 +1,13 @@ -FROM java:8-jdk +FROM jimschubert/8-jdk-alpine-mvn WORKDIR /generator + COPY target/lib/jetty-runner* /generator/jetty-runner.jar COPY target/*.war /generator/swagger-generator.war ENV GENERATOR_HOST=https://generator.swaggerhub.com/api/swagger.json -RUN apt-get update EXPOSE 8080 + CMD ["java", "-jar", "/generator/jetty-runner.jar", "/generator/swagger-generator.war"]