Unofficial docker image available for Amazon Linux 2023

i have managed to compile a swift 5.9.2 release toolchain for Amazon Linux 2023, and have pushed a (2GB) docker image here: tayloraswift/5.9.2-amazonlinux2023

note that to compile anything in release mode, it is necessary to pass -Xswiftc -use-ld=ld to the swift build invocation, because of incompatibility between and libstdc++.

for the sake of transparency, building this image invoked three dockerfiles:

dockerfile 1

dockerfile 2

FROM tayloraswift/swift-ci:amazonlinux2023

RUN mkdir swift-project
WORKDIR swift-project


RUN git clone --depth 1 --branch $SWIFT_CHECKOUT

WORKDIR /home/build-user/swift-project/swift

RUN utils/update-checkout --clone --tag $SWIFT_CHECKOUT

RUN --mount=type=cache,target=/swift-project/build \
    utils/build-script  \
    --preset=buildbot_linux,no_assertions,no_test \
    install_destdir=/home/build-user/swift-install \

dockerfile 3

FROM amazonlinux:2023

RUN yum -y update
# install sysadmin basics
RUN yum -y install sudo passwd
# install swift dependencies
RUN yum -y install \
    binutils \
    gcc \
    git \
    unzip \
    glibc-static \
    gzip \
    libbsd \
    libcurl-devel \
    libedit \
    libicu \
    libstdc++-static \
    libuuid \
    libxml2-devel \
    tar \
    tzdata \

# optional, but python, and iptables are very useful in a container
RUN sudo yum -y install \
    python3 \
    python3-devel \
    iptables \

# jemalloc
RUN sudo yum -y install bzip2 make
RUN curl \
    -L -o jemalloc-5.3.0.tar.bz2
RUN tar -xf jemalloc-5.3.0.tar.bz2
RUN cd jemalloc-5.3.0 && ./configure && make && sudo make install

COPY --from=swift-toolchain-builder:5.9.2 /usr/bin/ /usr/bin/
# install swift
COPY --from=swift-toolchain-builder:5.9.2 /home/build-user/swift-install /swift-install

RUN    cp -r /swift-install/usr/bin/* /usr/bin \
    && cp -r /swift-install/usr/include/* /usr/include/ \
    && cp -r /swift-install/usr/libexec/* /usr/libexec/ \
    && cp -r /swift-install/usr/lib/* /usr/lib/ \
    && cp -r /swift-install/usr/local/* /usr/local \
    && cp -r /swift-install/usr/share/* /usr/share \
    && rm -r /swift-install

# create the `ec2-user`, and switch to her
RUN useradd -ms /bin/bash ec2-user
RUN passwd -d ec2-user
RUN usermod -aG wheel ec2-user
USER ec2-user

WORKDIR /home/ec2-user/

# generate script that will run on terminal creation,
# enables showing the PWD prompt
RUN echo "PS1='\w\$ '" >> .bashrc
RUN echo "force_color_prompt=yes" >> .bashrc
ENV TERM xterm-256color

CMD sleep infinity


a 5.10 toolchain, compiled from the swift-5.10-RELEASE tag, is now available here: tayloraswift/5.10.0-amazonlinux2023

1 Like