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