|
| 1 | +FROM amazonlinux:2 AS base |
| 2 | +LABEL maintainer= "Swift Infrastructure <[email protected]>" |
| 3 | +LABEL description="Docker Container for the Swift programming language" |
| 4 | + |
| 5 | +RUN yum -y install \ |
| 6 | + binutils \ |
| 7 | + gcc \ |
| 8 | + git \ |
| 9 | + glibc-static \ |
| 10 | + gzip \ |
| 11 | + libbsd \ |
| 12 | + libcurl \ |
| 13 | + libedit \ |
| 14 | + libicu \ |
| 15 | + libsqlite \ |
| 16 | + libstdc++-static \ |
| 17 | + libuuid \ |
| 18 | + libxml2 \ |
| 19 | + tar \ |
| 20 | + tzdata \ |
| 21 | + zlib-devel |
| 22 | + |
| 23 | +# Everything up to here should cache nicely between Swift versions, assuming dev dependencies change little |
| 24 | + |
| 25 | +# gpg --keyid-format LONG -k FAF6989E1BC16FEA |
| 26 | +# pub rsa4096/FAF6989E1BC16FEA 2019-11-07 [SC] [expires: 2021-11-06] |
| 27 | +# 8A7495662C3CD4AE18D95637FAF6989E1BC16FEA |
| 28 | +# uid [ unknown] Swift Automatic Signing Key #3 <[email protected]> |
| 29 | +ARG SWIFT_SIGNING_KEY=8A7495662C3CD4AE18D95637FAF6989E1BC16FEA |
| 30 | +ARG SWIFT_PLATFORM=amazonlinux |
| 31 | +ARG OS_MAJOR_VER=2 |
| 32 | +ARG SWIFT_WEBROOT=https://swift.org/builds/development |
| 33 | + |
| 34 | +# This is a small trick to enable if/else for arm64 and amd64. |
| 35 | +# Because of https://bugs.swift.org/browse/SR-14872 we need adjust tar options. |
| 36 | +FROM base AS base-amd64 |
| 37 | +ARG OS_ARCH_SUFFIX= |
| 38 | +ARG ADDITIONAL_TAR_OPTIONS="--strip-components=1" |
| 39 | + |
| 40 | +FROM base AS base-arm64 |
| 41 | +ARG OS_ARCH_SUFFIX=-aarch64 |
| 42 | +ARG ADDITIONAL_TAR_OPTIONS= |
| 43 | + |
| 44 | +FROM base-$TARGETARCH AS final |
| 45 | + |
| 46 | +ARG OS_VER=$SWIFT_PLATFORM$OS_MAJOR_VER$OS_ARCH_SUFFIX |
| 47 | +ARG PLATFORM_WEBROOT="$SWIFT_WEBROOT/$SWIFT_PLATFORM$OS_MAJOR_VER$OS_ARCH_SUFFIX" |
| 48 | + |
| 49 | +RUN echo "${PLATFORM_WEBROOT}/latest-build.yml" |
| 50 | + |
| 51 | +RUN set -e; \ |
| 52 | + # - Latest Toolchain info |
| 53 | + export $(curl -s ${PLATFORM_WEBROOT}/latest-build.yml | grep 'download:' | sed 's/:[^:\/\/]/=/g') \ |
| 54 | + && export $(curl -s ${PLATFORM_WEBROOT}/latest-build.yml | grep 'download_signature:' | sed 's/:[^:\/\/]/=/g') \ |
| 55 | + && export DOWNLOAD_DIR=$(echo $download | sed "s/-${OS_VER}.tar.gz//g") \ |
| 56 | + && echo $DOWNLOAD_DIR > .swift_tag \ |
| 57 | + # - Download the GPG keys, Swift toolchain, and toolchain signature, and verify. |
| 58 | + && export GNUPGHOME="$(mktemp -d)" \ |
| 59 | + && curl -fsSL ${PLATFORM_WEBROOT}/${DOWNLOAD_DIR}/${download} -o latest_toolchain.tar.gz \ |
| 60 | + ${PLATFORM_WEBROOT}/${DOWNLOAD_DIR}/${download_signature} -o latest_toolchain.tar.gz.sig \ |
| 61 | + && curl -fSsL https://swift.org/keys/all-keys.asc | gpg --import - \ |
| 62 | + && gpg --batch --verify latest_toolchain.tar.gz.sig latest_toolchain.tar.gz \ |
| 63 | + # - Unpack the toolchain, set libs permissions, and clean up. |
| 64 | + && tar -xzf latest_toolchain.tar.gz --directory / ${ADDITIONAL_TAR_OPTIONS} \ |
| 65 | + && chmod -R o+r /usr/lib/swift \ |
| 66 | + && rm -rf "$GNUPGHOME" latest_toolchain.tar.gz.sig latest_toolchain.tar.gz \ |
| 67 | + |
| 68 | +# Print Installed Swift Version |
| 69 | +RUN swift --version |
| 70 | + |
| 71 | +RUN echo '[ ! -z "$TERM" -a -r /etc/motd ] && cat /etc/motd' \ |
| 72 | + >> /etc/bashrc; \ |
| 73 | + echo -e " ################################################################\n" \ |
| 74 | + "#\t\t\t\t\t\t\t\t#\n" \ |
| 75 | + "# Swift Nightly Docker Image\t\t\t\t\t#\n" \ |
| 76 | + "# Tag: $(cat .swift_tag)\t\t\t#\n" \ |
| 77 | + "#\t\t\t\t\t\t\t\t#\n" \ |
| 78 | + "################################################################\n" > /etc/motd |
| 79 | + |
| 80 | +RUN echo 'source /etc/bashrc' >> /root/.bashrc |
0 commit comments