Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 79 additions & 2 deletions java/8/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,84 @@
# docker build -t imqs/java-base:8-test --build-arg Maven_Nexus_User=$Maven_Nexus_User --build-arg Maven_Releases_Deployment=$Maven_Releases_Deployment --build-arg Maven_Snapshots_Deployment=$Maven_Snapshots_Deployment --build-arg Maven_Github_gerhardvanwyk=$Maven_Github_gerhardvanwyk .

FROM imqs/ubuntu-base

RUN apt-get update \
&& apt-get install openjdk-8-jre -y
RUN apt update && \
apt install -y \
openjdk-8-jdk \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we need JDK? We won't be developing on top of this image?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TL;DR: its adds 10mb to the image.

The idea is that the jar file gets created using this docker image. We do this with all our other services. It dramatically reduces the build job setups.

wget && \
rm -rf /var/lib/apt/lists/*

RUN wget https://www-us.apache.org/dist/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz -P /tmp && \
tar xf /tmp/apache-maven-*.tar.gz -C /opt && rm /tmp/apache-maven-*.tar.gz && \
mv /opt/apache-maven-* /opt/maven
ENV MAVEN_HOME=/opt/maven
ENV PATH=${MAVEN_HOME}/bin:${PATH}

ARG Maven_Nexus_User
ARG Maven_Releases_Deployment
ARG Maven_Snapshots_Deployment
ARG Maven_Github_gerhardvanwyk
RUN mkdir -p /root/.m2
RUN echo "<settings> \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again I don't think we need to be able to build in this container. Having said that:
So every image and therefore every project will have its own maven repository. This means that we will have a massive amount of duplication of the many shared libraries. It also means that it becomes awkward if you want to build locally using chnages pushed to your local .m2 folder?

Maybe I'm missing what you are trying to do?

We took this approach on our side: https://github.com/IMQS/imqs-wip-service/blob/team-asset-containers/build.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm... so two parts

  1. What I was trying to do with including the settings file in the base images is affectingly addressing the issues that the build.sh is bringing up in the start of the file. This keeps everything contained and self sustained. There is no dependency on the machine building the jar because everything is all ready setup inside the container.

  2. Crap... making changes in your local .m2 folder... thats a good point... as rare as this case may be, It will still be very annoying the day that someone wants to do something like this... The only solution I can think of is doing the same thing that we do for maps, and that is to build the base image with your changes your self. I could add a second dockerfile that copys your local .m2 into the container to streamline this process?

<mirrors> \
<mirror> \
<!--This sends everything else to /public --> \
<id>nexus</id> \
<mirrorOf>*</mirrorOf> \
<url>http://192.168.4.40:8081/nexus/content/groups/public</url> \
</mirror> \
</mirrors> \
<profiles> \
<profile> \
<id>nexus</id> \
<!--Enable snapshots for the built in central repo to direct --> \
<!--all requests to nexus via the mirror --> \
<repositories> \
<repository> \
<id>central</id> \
<url>http://central</url> \
<releases><enabled>true</enabled></releases> \
<snapshots><enabled>true</enabled></snapshots> \
</repository> \
</repositories> \
<pluginRepositories> \
<pluginRepository> \
<id>central</id> \
<url>http://central</url> \
<releases><enabled>true</enabled></releases> \
<snapshots><enabled>true</enabled></snapshots> \
</pluginRepository> \
</pluginRepositories> \
</profile> \
</profiles> \
<activeProfiles> \
<!--make the profile active all the time --> \
<activeProfile>nexus</activeProfile> \
</activeProfiles> \
\
<servers> \
<server> \
<id>nexus</id> \
<username>user</username> \
<password>$Maven_Nexus_User</password> \
</server> \
<server> \
<id>releases</id> \
<username>deployment</username> \
<password>$Maven_Releases_Deployment</password> \
</server> \
<server> \
<id>snapshots</id> \
<username>deployment</username> \
<password>$Maven_Snapshots_Deployment</password> \
</server> \
<server> \
<id>github</id> \
<username>gerhardvanwyk</username> \
<password>$Maven_Github_gerhardvanwyk</password> \
</server> \
</servers> \
</settings>" > /root/.m2/settings.xml

# Create a symlink to the real log directory
RUN mkdir -p /imqsvar
Expand Down
22 changes: 22 additions & 0 deletions java/8/Dockerfile-local-m2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# docker build -t imqs/java-base:8-test .

FROM imqs/ubuntu-base

RUN apt update && \
apt install -y \
openjdk-8-jdk \
wget && \
rm -rf /var/lib/apt/lists/*

RUN wget https://www-us.apache.org/dist/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz -P /tmp && \
tar xf /tmp/apache-maven-*.tar.gz -C /opt && rm /tmp/apache-maven-*.tar.gz && \
mv /opt/apache-maven-* /opt/maven
ENV MAVEN_HOME=/opt/maven
ENV PATH=${MAVEN_HOME}/bin:${PATH}

RUN mkdir -p /root/.m2
COPY ./ /root/.m2

# Create a symlink to the real log directory
RUN mkdir -p /imqsvar
RUN ln -s /var/log/imqs /imqsvar/logs
6 changes: 6 additions & 0 deletions java/8/build-local-m2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dockerfileDir=${PWD}

cd /home/`whoami`/.m2 && \
sudo docker build -t imqs/java-base:8-test -f ${dockerfileDir}/Dockerfile-local-m2 .

cd $dockerfileDir
10 changes: 10 additions & 0 deletions java/8/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Docker Local m2

If you are a developer and you have made changes to your local .m2 folder and
you are not satisfied with just testing your service natively then this is the
dockerfile for you.

By running the script called `build-local-m2` you can build the `java-base`
image using your own `.m2` folder in your home directory. You can then build
the docker image for java service and it will automatically use the local m2
docker image as a base.