|
| 1 | +FROM centos:7 |
| 2 | +LABEL maintainer= "Swift Infrastructure <[email protected]>" |
| 3 | +LABEL description="Docker Container for the Swift programming language" |
| 4 | + |
| 5 | +# CentOS 7 ships with git 1.x which is too old for the toolchain usage, using RH software collections to install git 2.x |
| 6 | +RUN yum install -y centos-release-scl-rh |
| 7 | + |
| 8 | +RUN yum install shadow-utils.x86_64 -y \ |
| 9 | + binutils \ |
| 10 | + gcc \ |
| 11 | + rh-git227-git \ |
| 12 | + glibc-static \ |
| 13 | + libbsd-devel \ |
| 14 | + libcurl-devel \ |
| 15 | + libedit \ |
| 16 | + libedit-devel \ |
| 17 | + libicu-devel \ |
| 18 | + libstdc++-static \ |
| 19 | + libxml2-devel \ |
| 20 | + pkg-config \ |
| 21 | + python2 \ |
| 22 | + python3 \ |
| 23 | + sqlite \ |
| 24 | + unzip \ |
| 25 | + zip \ |
| 26 | + zlib-devel |
| 27 | + |
| 28 | +# Enable git 2.x from RH software collections for both login and non-login shells |
| 29 | +RUN ln -s /opt/rh/rh-git227/enable /etc/profile.d/git.sh |
| 30 | +ENV ENV=/etc/profile.d/git.sh |
| 31 | +ENV BASH_ENV=$ENV |
| 32 | + |
| 33 | +RUN sed -i -e 's/\*__block/\*__libc_block/g' /usr/include/unistd.h |
| 34 | + |
| 35 | +# Everything up to here should cache nicely between Swift versions, assuming dev dependencies change little |
| 36 | + |
| 37 | +# gpg --keyid-format LONG -k F167DF1ACF9CE069 |
| 38 | +# pub rsa4096/F167DF1ACF9CE069 2021-11-08 [SC] [expires: 2025-11-09] |
| 39 | +# E813C892820A6FA13755B268F167DF1ACF9CE069 |
| 40 | +# uid [ unknown] Swift Automatic Signing Key #4 <[email protected]> |
| 41 | +ARG SWIFT_SIGNING_KEY=E813C892820A6FA13755B268F167DF1ACF9CE069 |
| 42 | +ARG SWIFT_PLATFORM=centos |
| 43 | +ARG OS_MAJOR_VER=7 |
| 44 | +ARG SWIFT_WEBROOT=https://download.swift.org/swift-6.2-branch |
| 45 | + |
| 46 | +ENV SWIFT_SIGNING_KEY=$SWIFT_SIGNING_KEY \ |
| 47 | + SWIFT_PLATFORM=$SWIFT_PLATFORM \ |
| 48 | + OS_MAJOR_VER=$OS_MAJOR_VER \ |
| 49 | + OS_VER=$SWIFT_PLATFORM$OS_MAJOR_VER \ |
| 50 | + SWIFT_WEBROOT="$SWIFT_WEBROOT/$SWIFT_PLATFORM$OS_MAJOR_VER" |
| 51 | + |
| 52 | +RUN echo "${SWIFT_WEBROOT}/latest-build.yml" |
| 53 | + |
| 54 | +RUN set -e; \ |
| 55 | + # - Latest Toolchain info |
| 56 | + export $(curl -s ${SWIFT_WEBROOT}/latest-build.yml | grep 'download:' | sed 's/:[^:\/\/]/=/g') \ |
| 57 | + && export $(curl -s ${SWIFT_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 -fL ${SWIFT_WEBROOT}/${DOWNLOAD_DIR}/${download} -o latest_toolchain.tar.gz \ |
| 63 | + ${SWIFT_WEBROOT}/${DOWNLOAD_DIR}/${download_signature} -o latest_toolchain.tar.gz.sig \ |
| 64 | + && curl -fL 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 | + |
| 71 | +# The devtoolset-8 that the Swift runtime is built against uses new |
| 72 | +# functionality in the backdeploy `libstdc++_noshared.a` in devtoolset-a. |
| 73 | +# A linkerscript in the devtoolset ensures that it is picked up appropriately. |
| 74 | +# When dynamically linking the runtime, this static archive is merged into the |
| 75 | +# shared object. When static linking, the compat library needs to be available |
| 76 | +# to be merged into the final shared object/executable. |
| 77 | +# |
| 78 | +# Symlink it from the devtoolset into the static swift resource directory |
| 79 | +RUN yum install -y centos-release-scl |
| 80 | +RUN yum install -y devtoolset-8 |
| 81 | +RUN ln -s /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++_nonshared.a /usr/lib/swift_static/linux && \ |
| 82 | + ln -s /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.so /usr/lib/swift_static/linux |
| 83 | + |
| 84 | +# Print Installed Swift Version |
| 85 | +RUN swift --version |
| 86 | + |
| 87 | +RUN echo "[ -n \"\${TERM:-}\" -a -r /etc/motd ] && cat /etc/motd" >> /etc/bashrc; \ |
| 88 | + ( \ |
| 89 | + printf "################################################################\n"; \ |
| 90 | + printf "# %-60s #\n" ""; \ |
| 91 | + printf "# %-60s #\n" "Swift Nightly Docker Image"; \ |
| 92 | + printf "# %-60s #\n" "Tag: $(cat .swift_tag)"; \ |
| 93 | + printf "# %-60s #\n" ""; \ |
| 94 | + printf "################################################################\n" \ |
| 95 | + ) > /etc/motd |
0 commit comments