|
| 1 | +FROM amazonlinux:2 |
| 2 | +LABEL maintainer= "Swift Infrastructure <[email protected]>" |
| 3 | +LABEL description="Docker Container for the Swift programming language" |
| 4 | + |
| 5 | +# Everything up to here should cache nicely between Swift versions, assuming dev dependencies change little |
| 6 | + |
| 7 | +# gpg --keyid-format LONG -k FAF6989E1BC16FEA |
| 8 | +# pub rsa4096/FAF6989E1BC16FEA 2019-11-07 [SC] [expires: 2021-11-06] |
| 9 | +# 8A7495662C3CD4AE18D95637FAF6989E1BC16FEA |
| 10 | +# uid [ unknown] Swift Automatic Signing Key #3 <[email protected]> |
| 11 | +ARG SWIFT_SIGNING_KEY=8A7495662C3CD4AE18D95637FAF6989E1BC16FEA |
| 12 | +ARG SWIFT_PLATFORM=amazonlinux |
| 13 | +ARG OS_MAJOR_VER=2 |
| 14 | +ARG SWIFT_WEBROOT=https://swift.org/builds/swift-5.2-branch |
| 15 | + |
| 16 | +ENV SWIFT_SIGNING_KEY=$SWIFT_SIGNING_KEY \ |
| 17 | + SWIFT_PLATFORM=$SWIFT_PLATFORM \ |
| 18 | + OS_MAJOR_VER=$OS_MAJOR_VER \ |
| 19 | + OS_VER=$SWIFT_PLATFORM$OS_MAJOR_VER \ |
| 20 | + SWIFT_WEBROOT="$SWIFT_WEBROOT/$SWIFT_PLATFORM$OS_MAJOR_VER" |
| 21 | + |
| 22 | +RUN echo "${SWIFT_WEBROOT}/latest-build.yml" |
| 23 | + |
| 24 | +RUN set -e; \ |
| 25 | + # - Latest Toolchain info |
| 26 | + export $(curl -s ${SWIFT_WEBROOT}/latest-build.yml | grep 'download:' | sed 's/:[^:\/\/]/=/g') \ |
| 27 | + && export $(curl -s ${SWIFT_WEBROOT}/latest-build.yml | grep 'download_signature:' | sed 's/:[^:\/\/]/=/g') \ |
| 28 | + && export DOWNLOAD_DIR=$(echo $download | sed "s/-${OS_VER}.tar.gz//g") \ |
| 29 | + && echo $DOWNLOAD_DIR > .swift_tag \ |
| 30 | + # - Download the GPG keys, Swift toolchain, and toolchain signature, and verify. |
| 31 | + && export GNUPGHOME="$(mktemp -d)" \ |
| 32 | + && curl -fsSL ${SWIFT_WEBROOT}/${DOWNLOAD_DIR}/${download} -o latest_toolchain.tar.gz \ |
| 33 | + ${SWIFT_WEBROOT}/${DOWNLOAD_DIR}/${download_signature} -o latest_toolchain.tar.gz.sig \ |
| 34 | + && curl -fSsL https://swift.org/keys/all-keys.asc | gpg --import - \ |
| 35 | + && gpg --batch --verify latest_toolchain.tar.gz.sig latest_toolchain.tar.gz \ |
| 36 | + # - Unpack the toolchain, set libs permissions, and clean up. |
| 37 | + && yum -y install tar gzip \ |
| 38 | + && tar -xzf latest_toolchain.tar.gz --directory / --strip-components=1 ${DOWNLOAD_DIR}-${OS_VER}/usr/lib/swift/linux \ |
| 39 | + && chmod -R o+r /usr/lib/swift \ |
| 40 | + && rm -rf "$GNUPGHOME" latest_toolchain.tar.gz.sig latest_toolchain.tar.gz \ |
| 41 | + && yum autoremove -y tar gzip |
| 42 | + |
| 43 | +RUN echo '[ ! -z "$TERM" -a -r /etc/motd ] && cat /etc/motd' \ |
| 44 | + >> /etc/bashrc; \ |
| 45 | + echo -e " ################################################################\n" \ |
| 46 | + "#\t\t\t\t\t\t\t\t#\n" \ |
| 47 | + "# Swift Nightly Docker Image\t\t\t\t\t#\n" \ |
| 48 | + "# Tag: $(cat .swift_tag)\t\t\t#\n" \ |
| 49 | + "#\t\t\t\t\t\t\t\t#\n" \ |
| 50 | + "################################################################\n" > /etc/motd |
| 51 | + |
| 52 | +RUN echo 'source /etc/bashrc' >> /root/.bashrc |
0 commit comments