Skip to content

Commit

Permalink
java
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Sep 19, 2024
1 parent cbb1818 commit 239ee14
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
86 changes: 86 additions & 0 deletions docker/java/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Copyright (c) 2024 Yegor Bugayenko
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met: 1) Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer. 2) Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution. 3) Neither the name of the rultor.com nor
# the names of its contributors may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
# OF THE POSSIBILITY OF SUCH DAMAGE.

FROM ubuntu:24.04
LABEL Description="RULTOR image for simple Java+Maven projects" Version="0.0.0"
WORKDIR /tmp

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get clean \
&& apt-get update -y --fix-missing \
&& apt-get -y install locales \
&& locale-gen en_US.UTF-8 \
&& dpkg-reconfigure locales \
&& echo "LC_ALL=en_US.UTF-8\nLANG=en_US.UTF-8\nLANGUAGE=en_US.UTF-8" > /etc/default/locale \
&& echo 'export LC_ALL=en_US.UTF-8' >> /root/.profile \
&& echo 'export LANG=en_US.UTF-8' >> /root/.profile \
&& echo 'export LANGUAGE=en_US.UTF-8' >> /root/.profile

ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US.UTF-8

RUN apt-get -y --no-install-recommends install \
curl=* \
sudo=* \
git=* \
unzip=* \
zip=* \
wget=* \
gnupg2=* \
libcurl4-gnutls-dev=* \
libxml2-utils=* \
libjpeg-dev=* \
build-essential=* \
ruby-dev=* libmagic-dev=* zlib1g-dev=* openssl=* \
&& apt-get clean

ENV MAVEN_OPTS=-Xmx1g
ENV JAVA_OPTS=-Xmx1g
ENV JAVA_HOME=/usr/lib/jvm/java-17
RUN apt-get -y install ca-certificates openjdk-11-jdk openjdk-17-jdk \
&& update-java-alternatives --set $(ls /usr/lib/jvm | grep java-1.11) \
&& ln -s "/usr/lib/jvm/$(ls /usr/lib/jvm | grep java-1.11)" /usr/lib/jvm/java-11 \
&& ln -s "/usr/lib/jvm/$(ls /usr/lib/jvm | grep java-1.17)" /usr/lib/jvm/java-17 \
&& echo 'export JAVA_HOME=/usr/lib/jvm/java-11' >> /root/.profile \
&& bash -c '[[ "$(javac --version)" =~ "11.0" ]]'

ENV MAVEN_VERSION=3.9.6
ENV M2_HOME=/usr/local/apache-maven/apache-maven-${MAVEN_VERSION}
RUN echo 'export M2_HOME=/usr/local/apache-maven/apache-maven-${MAVEN_VERSION}' >> /root/.profile \
&& wget --quiet "https://dlcdn.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz" \
&& mkdir -p /usr/local/apache-maven \
&& mv "apache-maven-${MAVEN_VERSION}-bin.tar.gz" /usr/local/apache-maven \
&& tar xzvf "/usr/local/apache-maven/apache-maven-${MAVEN_VERSION}-bin.tar.gz" -C /usr/local/apache-maven/ \
&& update-alternatives --install /usr/bin/mvn mvn "${M2_HOME}/bin/mvn" 1 \
&& update-alternatives --config mvn \
&& mvn -version \
&& bash -c '[[ "$(mvn --version)" =~ "${MAVEN_VERSION}" ]]'

ENTRYPOINT ["/bin/bash", "--login", "-c"]
15 changes: 15 additions & 0 deletions docker/java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Docker Image for Java Projects

Build it like this:

```bash
docker build --platform=linux/x86_64 -t yegor256/rultor-java .
```

Then, deploy it:

```bash
docker push yegor256/rultor-java
```

This image is used by [qbash](https://github.com/yegor256/qbash) and others.

0 comments on commit 239ee14

Please sign in to comment.