Skip to content

Commit e270316

Browse files
committed
Add buildx image for centos 8
1 parent 48b4d96 commit e270316

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
FROM centos:8 AS base
2+
LABEL maintainer="Swift Infrastructure <[email protected]>"
3+
LABEL description="Docker Container for the Swift programming language"
4+
5+
RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
6+
7+
RUN yum install --enablerepo=powertools -y \
8+
binutils \
9+
gcc \
10+
git \
11+
glibc-static \
12+
libbsd-devel \
13+
libedit \
14+
libedit-devel \
15+
libicu-devel \
16+
libstdc++-static \
17+
pkg-config \
18+
python2 \
19+
sqlite \
20+
zlib-devel
21+
22+
RUN ln -s /usr/bin/python2 /usr/bin/python
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=centos
32+
ARG OS_MAJOR_VER=8
33+
ARG SWIFT_WEBROOT=https://swift.org/builds/development
34+
35+
# This is a small trick to enable if/else for arm64 and amd64.
36+
# Because of https://bugs.swift.org/browse/SR-14872 we need adjust tar options.
37+
FROM base AS base-amd64
38+
ARG OS_ARCH_SUFFIX=
39+
ARG ADDITIONAL_TAR_OPTIONS="--strip-components=1"
40+
41+
FROM base AS base-arm64
42+
ARG OS_ARCH_SUFFIX=-aarch64
43+
ARG ADDITIONAL_TAR_OPTIONS=
44+
45+
FROM base-$TARGETARCH AS final
46+
47+
ARG OS_VER=$SWIFT_PLATFORM$OS_MAJOR_VER$OS_ARCH_SUFFIX
48+
ARG PLATFORM_WEBROOT="$SWIFT_WEBROOT/$SWIFT_PLATFORM$OS_MAJOR_VER$OS_ARCH_SUFFIX"
49+
50+
RUN echo "${PLATFORM_WEBROOT}/latest-build.yml"
51+
52+
RUN set -e; \
53+
# - Latest Toolchain info
54+
export $(curl -s ${PLATFORM_WEBROOT}/latest-build.yml | grep 'download:' | sed 's/:[^:\/\/]/=/g') \
55+
&& export $(curl -s ${PLATFORM_WEBROOT}/latest-build.yml | grep 'download_signature:' | sed 's/:[^:\/\/]/=/g') \
56+
&& export DOWNLOAD_DIR=$(echo $download | sed "s/-${OS_VER}.tar.gz//g") \
57+
&& echo $DOWNLOAD_DIR > .swift_tag \
58+
# - Download the GPG keys, Swift toolchain, and toolchain signature, and verify.
59+
&& export GNUPGHOME="$(mktemp -d)" \
60+
&& curl -fsSL ${PLATFORM_WEBROOT}/${DOWNLOAD_DIR}/${download} -o latest_toolchain.tar.gz \
61+
${PLATFORM_WEBROOT}/${DOWNLOAD_DIR}/${download_signature} -o latest_toolchain.tar.gz.sig \
62+
&& curl -fSsL https://swift.org/keys/all-keys.asc | gpg --import - \
63+
&& gpg --batch --verify latest_toolchain.tar.gz.sig latest_toolchain.tar.gz \
64+
# - Unpack the toolchain, set libs permissions, and clean up.
65+
&& tar -xzf latest_toolchain.tar.gz --directory / ${ADDITIONAL_TAR_OPTIONS} \
66+
&& chmod -R o+r /usr/lib/swift \
67+
&& rm -rf "$GNUPGHOME" latest_toolchain.tar.gz.sig latest_toolchain.tar.gz
68+
69+
# Print Installed Swift Version
70+
RUN swift --version
71+
72+
RUN echo '[ ! -z "$TERM" -a -r /etc/motd ] && cat /etc/motd' \
73+
>> /etc/bashrc; \
74+
echo -e " ################################################################\n" \
75+
"#\t\t\t\t\t\t\t\t#\n" \
76+
"# Swift Nightly Docker Image\t\t\t\t\t#\n" \
77+
"# Tag: $(cat .swift_tag)\t\t\t#\n" \
78+
"#\t\t\t\t\t\t\t\t#\n" \
79+
"################################################################\n" > /etc/motd

0 commit comments

Comments
 (0)