Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build docker image in one step #93

Open
mark-sivill-kong opened this issue Dec 22, 2022 · 0 comments
Open

Unable to build docker image in one step #93

mark-sivill-kong opened this issue Dec 22, 2022 · 0 comments

Comments

@mark-sivill-kong
Copy link

mark-sivill-kong commented Dec 22, 2022

Hi,

The current docker file requires a maven build to occur first, which requires a user to set up Java and Maven on their local machine.

By using Docker multi-stage builds https://docs.docker.com/build/building/multi-stage/ the requirement for a local Java and Maven setup can be removed.

Below is an example of how this can be done.

Thanks

Mark

#
# mark-sivill-kong - Dec 2022
# 
FROM openjdk:8-jdk-alpine

WORKDIR /swagger-petstore

RUN apk add maven

COPY src/ /swagger-petstore/src
COPY pom.xml /swagger-petstore/pom.xml

RUN mvn --quiet package

#
# copy build assets into run
#
FROM openjdk:8-jre-alpine

WORKDIR /swagger-petstore

COPY src/main/resources/openapi.yaml /swagger-petstore/openapi.yaml
COPY inflector.yaml /swagger-petstore/
COPY --from=0 /swagger-petstore/target/lib/jetty-runner.jar /swagger-petstore/jetty-runner.jar
COPY --from=0 /swagger-petstore/target/*.war /swagger-petstore/server.war

EXPOSE 8080

CMD ["java", "-jar", "-DswaggerUrl=openapi.yaml", "/swagger-petstore/jetty-runner.jar", "--log", "/var/log/yyyy_mm_dd-requests.log", "/swagger-petstore/server.war"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant