From 239ee14ead68e928742c099f9685410de5c1281c Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 19 Sep 2024 15:41:30 +0700 Subject: [PATCH] java --- docker/java/Dockerfile | 86 ++++++++++++++++++++++++++++++++++++++++++ docker/java/README.md | 15 ++++++++ 2 files changed, 101 insertions(+) create mode 100644 docker/java/Dockerfile create mode 100644 docker/java/README.md diff --git a/docker/java/Dockerfile b/docker/java/Dockerfile new file mode 100644 index 0000000000..a5b6773470 --- /dev/null +++ b/docker/java/Dockerfile @@ -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"] diff --git a/docker/java/README.md b/docker/java/README.md new file mode 100644 index 0000000000..f11b84f0e7 --- /dev/null +++ b/docker/java/README.md @@ -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.