Azure / draft-classic

A tool for developers to create cloud-native applications on Kubernetes.
https://draft.sh
MIT License
3.93k stars 397 forks source link

Maven configuration for multi-stage builds #728

Open arun-gupta opened 6 years ago

arun-gupta commented 6 years ago

Generate Dockerfile for a Java application looks like:

FROM maven:3.5-jdk-8 as BUILD

COPY . /usr/src/app
RUN mvn --batch-mode -f /usr/src/app/pom.xml clean package

FROM openjdk:8-jdk
ENV PORT 4567
EXPOSE 4567
COPY --from=BUILD /usr/src/app/target /opt/target
WORKDIR /opt/target

CMD ["/bin/bash", "-c", "find -type f -name '*.jar' | xargs java -jar"]

While using multi-stage build is great, but this means that the first run of this file will take forever as it'll download the Maven repository. There should be an option to map local Maven repository using volume mapping. This will significantly reduce the build time for developers who already have Maven setup.

Identified during hacking with @michelleN at #KubeCon

dkirrane commented 6 years ago

I have the same problem. The Maven Docker image (https://hub.docker.com/_/maven/) that's used by the Draft java pack allows you to use a host path volume or use a named volume for the Maven repo e.g.

docker volume create --name maven-repo
docker run -it -v maven-repo:/root/.m2 maven mvn clean install

Or alternatively are there any plans for draft to support docker-compose? If so, draft could use docker-compose.yaml to configure the required volumes.

omjego commented 4 years ago

Any updates on this? Is this feature going to be implemented in the near future? @arun-gupta