This is my simple Dockerfile. The issue is SCALA_VERSION variable in the line wget -q --no-cookies ... does not get interpolated. I am not sure how to fix that. I appreciate any help or hint.
ARG SCALA_MAJOR_VERSION="2.13"
ARG SCALA_MINOR_VERSION="7"
ARG SCALA_VERSION="$SCALA_MAJOR_VERSION.$SCALA_MINOR_VERSION"
FROM openjdk:18-jdk-alpine AS base
LABEL version="$SCALA_VERSION"
WORKDIR /usr/lib
RUN apk add --no-cache bash \
&& apk add --no-cache --virtual=build-dependencies wget ca-certificates \
&& wget -q --no-cookies "https://downloads.lightbend.com/scala/${SCALA_VERSION}/scala-${SCALA_VERSION}.tgz" -O - | gunzip | tar x \
&& apk del build-dependencies \
&& rm -rf /tmp/*
Logs:
➜ compiler-toolchain git:(master) ✗ docker build . -t cool
Sending build context to Docker daemon 16.54MB
Step 1/18 : ARG SCALA_MAJOR_VERSION="2.13"
Step 2/18 : ARG SCALA_MINOR_VERSION="7"
Step 3/18 : ARG SCALA_VERSION="$SCALA_MAJOR_VERSION.$SCALA_MINOR_VERSION"
Step 4/18 : FROM openjdk:18-jdk-alpine AS base
---> c89120dcca4c
Step 5/18 : LABEL maintainer="[email protected]"
---> Using cache
---> eb84f71065ca
Step 6/18 : LABEL version="$SCALA_VERSION"
---> Using cache
---> 23f11d22b6cb
Step 7/18 : WORKDIR /usr/lib
---> Using cache
---> 8762269e3700
Step 8/18 : RUN apk add --no-cache bash && apk add --no-cache --virtual=build-dependencies wget ca-certificates && wget -q --no-cookies "https://downloads.lightbend.com/scala/${SCALA_VERSION}/scala-${SCALA_VERSION}.tgz" -O - | gunzip | tar x && apk del build-dependencies && rm -rf /tmp/*
---> Running in 0cc02cf39a42
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
(1/4) Installing ncurses-terminfo-base (6.3_p20211120-r0)
(2/4) Installing ncurses-libs (6.3_p20211120-r0)
(3/4) Installing readline (8.1.1-r0)
(4/4) Installing bash (5.1.8-r0)
Executing bash-5.1.8-r0.post-install
Executing busybox-1.34.1-r3.trigger
OK: 10 MiB in 24 packages
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
(1/4) Installing libunistring (0.9.10-r1)
(2/4) Installing libidn2 (2.3.2-r0)
(3/4) Installing wget (1.21.2-r2)
(4/4) Installing build-dependencies (20211220.220536)
Executing busybox-1.34.1-r3.trigger
OK: 13 MiB in 28 packages
gunzip: invalid magic
tar: short read
The command '/bin/sh -c apk add --no-cache bash && apk add --no-cache --virtual=build-dependencies wget ca-certificates && wget -q --no-cookies "https://downloads.lightbend.com/scala/${SCALA_VERSION}/scala-${SCALA_VERSION}.tgz" -O - | gunzip | tar x && apk del build-dependencies && rm -rf /tmp/*' returned a non-zero code: 1
1.gunziphad invalid magic; it never even got to thewgetpart.SCALA_VERSIONand hardcode2.13.7it works perfectly fine.