-
-
Save LuanComputacao/6cf199fc577f7ee5fb85a504176d78ca to your computer and use it in GitHub Desktop.
# | |
# Oracle Java 7 Dockerfile | |
# | |
# https://github.com/dockerfile/java | |
# https://github.com/dockerfile/java/tree/master/oracle-java7 | |
# | |
# Pull base image. | |
FROM alpine as build | |
ARG MAVEN_VERSION=3.6.3 | |
ARG USER_HOME_DIR="/root" | |
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries | |
# Install Java. | |
RUN apk --update --no-cache add openjdk7 curl | |
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \ | |
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \ | |
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \ | |
&& rm -f /tmp/apache-maven.tar.gz \ | |
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn | |
ENV MAVEN_HOME /usr/share/maven | |
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" | |
# Define working directory. | |
WORKDIR /data | |
# Define commonly used JAVA_HOME variable | |
ENV JAVA_HOME /usr/lib/jvm/default-jvm/ | |
# Define default command. | |
CMD ["mvn", "--version"] | |
# Spring docker sample | |
# FROM openjdk:8-jdk-alpine | |
# VOLUME /tmp | |
# ARG JAR_FILE | |
# COPY ${JAR_FILE} app.jar | |
# ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] |
@LuanComputacao @antonTroyan you need to update the version defined of MVN to at least 3.6.3. See available versions on remote at: https://apache.osuosl.org/maven/maven-3/
Thanks, @zerjioang
I did the update!
Hello, I'm trying to install java but from a databricks image. Do you know if this is posible? I got this error:
=> ERROR [4/9] RUN apk --update --no-cache add openjdk7 curl
[4/9] RUN apk --update --no-cache add openjdk7 curl:
#8 0.314 /bin/sh: 1: apk: not found
executor failed running [/bin/sh -c apk --update --no-cache add openjdk7 curl]: exit code: 127
and this is my code:
`FROM databricksruntime/standard
WORKDIR /app
COPY . .
ARG MAVEN_VERSION=3.6.3
ARG USER_HOME_DIR="/root"
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries
RUN apk --update --no-cache add openjdk7 curl
RUN mkdir -p /usr/share/maven /usr/share/maven/ref
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1
&& rm -f /tmp/apache-maven.tar.gz
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
RUN mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get
-DrepoUrl=https://mvnrepository.com/artifact/com.crealytics/spark-excel_2.12/0.14.0
-Dartifact=com.crealytics:spark-excel_2.12:0.14.0 &&
mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get
-DrepoUrl=https://mvnrepository.com/artifact/mysql/mysql-connector-java
-Dartifact=mysql:mysql-connector-java:8.0.29
RUN apt-get update && apt-get install -y python3-pip
RUN sudo apt-get install -y libpq-dev
RUN pip install -r /app/requirements.txt
CMD ["python3"]`
This is an absolutely horrible solution to the problem. Once they delete the version on the remote you can't build the image anymore and are required to change it manually every time a new minor version is out.
This is a sketch script. You can improve it using many techniques. I suggest you use env vars or a script that automates versioning as needed for your code base. And not least, be kind!
@Haarolean
@LuanComputacao sorry if I offended your sketch or you personally. Didn't seem sketchy enough for me, and considering that it's the core feature of this sketch, I find it lacking flexibility if I need to update my dockerfile every week or so.
For the ones not wishing to manually replace maven version in a dockerfile every time a new release is out (since the repo used in this dockerfile deletes the old packages once the new is out), here's my take on automatically downloading the latest stable maven version:
https://gist.github.com/Haarolean/a2a8acf07dfd60cbd68bfdfd20ca9195
Cheers
Step 8/13 : RUN mkdir -p /usr/share/maven /usr/share/maven/ref && curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz && tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 && rm -f /tmp/apache-maven.tar.gz && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
---> Running in 6117c95afa87
curl: (22) The requested URL returned error: 404 Not Found