1+ FROM fedora:41 AS base
2+ LABEL maintainer="Swift Infrastructure <swift-infrastructure@forums.swift.org>"
3+ LABEL description="Docker Container for the Swift programming language"
4+
5+ RUN yum -y install \
6+ binutils \
7+ gcc \
8+ git \
9+ zip \
10+ unzip \
11+ libcurl-devel \
12+ libedit-devel \
13+ libicu-devel \
14+ sqlite-devel \
15+ libuuid-devel \
16+ libxml2-devel \
17+ python3-devel \
18+ libstdc++-devel \
19+ libstdc++-static \
20+ gnupg
21+
22+
23+ ARG SWIFT_SIGNING_KEY=E813C892820A6FA13755B268F167DF1ACF9CE069
24+ ARG SWIFT_PLATFORM=fedora41
25+ ARG SWIFT_VERSION=6.3
26+ ARG SWIFT_BRANCH=swift-${SWIFT_VERSION}-release
27+ ARG SWIFT_TAG=swift-${SWIFT_VERSION}-RELEASE
28+ ARG SWIFT_WEBROOT=https://download.swift.org/swift-6.3-branch
29+ ARG SWIFT_WEBROOT="$SWIFT_WEBROOT/$SWIFT_PLATFORM"
30+ ARG SWIFT_PREFIX=/opt/swift/${SWIFT_VERSION}
31+
32+ # This is a small trick to enable if/else for arm64 and amd64.
33+ # Because of https://bugs.swift.org/browse/SR-14872 we need adjust tar options.
34+ FROM base AS base-amd64
35+ ARG OS_ARCH_SUFFIX=
36+
37+ FROM base AS base-arm64
38+ ARG OS_ARCH_SUFFIX=-aarch64
39+
40+ FROM base-$TARGETARCH AS final
41+
42+ ENV SWIFT_SIGNING_KEY=$SWIFT_SIGNING_KEY \
43+ SWIFT_PLATFORM=$SWIFT_PLATFORM \
44+ SWIFT_VERSION=$SWIFT_VERSION \
45+ SWIFT_BRANCH=$SWIFT_BRANCH \
46+ SWIFT_TAG=$SWIFT_TAG \
47+ SWIFT_WEBROOT=$SWIFT_WEBROOT \
48+ SWIFT_PREFIX=$SWIFT_PREFIX
49+
50+ RUN set -e; \
51+ ARCH_NAME="$(rpm --eval '%{_arch}')" ; \
52+ url=; \
53+ case "${ARCH_NAME##*-}" in \
54+ 'x86_64' ) \
55+ OS_ARCH_SUFFIX='' ; \
56+ ;; \
57+ 'aarch64' ) \
58+ OS_ARCH_SUFFIX='-aarch64' ; \
59+ ;; \
60+ *) echo >&2 "error: unsupported architecture: '$ARCH_NAME'" ; exit 1 ;; \
61+ esac; \
62+ export $(curl -s ${SWIFT_WEBROOT}${OS_ARCH_SUFFIX}/latest-build.yml | grep 'download:' | sed 's/:[^:\/\/ ]/=/g' ) \
63+ && export $(curl -s ${SWIFT_WEBROOT}${OS_ARCH_SUFFIX}/latest-build.yml | grep 'download_signature:' | sed 's/:[^:\/\/ ]/=/g' ) \
64+ && export DOWNLOAD_DIR=$(echo $download | sed "s/-${SWIFT_PLATFORM}${OS_ARCH_SUFFIX}.tar.gz//g" ) \
65+ && echo $DOWNLOAD_DIR > .swift_tag \
66+ # - Download the GPG keys, Swift toolchain, and toolchain signature, and verify.
67+ && export GNUPGHOME="$(mktemp -d)" \
68+ && curl -fsSL ${SWIFT_WEBROOT}${OS_ARCH_SUFFIX}/${DOWNLOAD_DIR}/${download} -o latest_toolchain.tar.gz \
69+ ${SWIFT_WEBROOT}${OS_ARCH_SUFFIX}/${DOWNLOAD_DIR}/${download} -o latest_toolchain.tar.gz.sig \
70+ && curl -fSsL --compressed https://swift.org/keys/all-keys.asc | gpg --import - \
71+ # - Unpack the toolchain, set libs permissions, and clean up.
72+ && mkdir -p $SWIFT_PREFIX \
73+ && tar -xzf latest_toolchain.tar.gz --directory $SWIFT_PREFIX --strip-components=1 \
74+ && chmod -R o+r $SWIFT_PREFIX/usr/lib/swift \
75+ && rm -rf "$GNUPGHOME" latest_toolchain.tar.gz.sig latest_toolchain.tar.gz
76+
77+ ENV PATH="${SWIFT_PREFIX}/usr/bin:${PATH}"
78+
79+ # Print Installed Swift Version
80+ RUN swift --version
0 commit comments