Last active
August 12, 2020 14:37
-
-
Save nebhale/fdffc2d18f0b8a595add91e73371274f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Download and verify file | |
# Args: $DOWNLOAD_URI, $REFRESH_TOKEN, $SHA256 | |
FROM ubuntu:bionic AS retrieve | |
RUN apt-get update && apt-get install --no-install-recommends -y \ | |
ca-certificates \ | |
curl \ | |
jq \ | |
&& rm -rf /var/lib/apt/lists/* | |
ARG REFRESH_TOKEN | |
RUN curl -sSL -X POST \ | |
https://network.pivotal.io/api/v2/authentication/access_tokens \ | |
-d "{ \"refresh_token\": \"${REFRESH_TOKEN}\" }" \ | |
| jq -r .access_token \ | |
> access_token | |
ARG DOWNLOAD_URI | |
RUN curl -L \ | |
-H "Authorization: Bearer $(cat access_token)" \ | |
$DOWNLOAD_URI \ | |
> download.tar.gz | |
ARG SHA256 | |
RUN echo "${SHA256} download.tar.gz" > sha256sums \ | |
&& sha256sum -c sha256sums 2>&1 | grep OK | |
# Install File | |
FROM ubuntu:bionic | |
ENV JAVA_HOME /opt/openjdk | |
ENV PATH $JAVA_HOME/bin:$PATH | |
COPY --from=retrieve download.tar.gz /tmp/download.tar.gz | |
RUN mkdir -p /opt/openjdk \ | |
&& cd /opt/openjdk \ | |
&& tar xzf /tmp/download.tar.gz --strip-components=1 \ | |
&& rm /tmp/download.tar.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment