Skip to content

Commit

Permalink
Updated Docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Nov 17, 2022
1 parent 144ff82 commit 2558c03
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 54 deletions.
5 changes: 3 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM debian:bullseye

# [Option] Install zsh
# Install zsh
ARG INSTALL_ZSH="true"
# [Option] Upgrade OS packages to their latest versions

# Upgrade OS packages to their latest versions
ARG UPGRADE_PACKAGES="true"

# Install needed packages and setup non-root user.
Expand Down
15 changes: 0 additions & 15 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,6 @@ jobs:
steps:
- name: Check out GitHub repo
uses: actions/checkout@v2
- name: Download Swift runtime
run: |
export SRC_ROOT=$GITHUB_WORKSPACE
export DOWNLOAD_FILE=$SRC_ROOT/build/swift-armv7.tar.gz
export TAR_URL=https://github.com/colemancda/swift-armv7/releases/download/0.5.1/swift-armv7.tar.gz
mkdir -p $SRC_ROOT/build
mkdir -p $SRC_ROOT/build/swift-linux-armv7-install
wget -q $TAR_URL -O $DOWNLOAD_FILE
cd $SRC_ROOT/build/swift-linux-armv7-install
tar -xvf $DOWNLOAD_FILE
rm -rf $DOWNLOAD_FILE
- name: Download Debian 11 sysroot
run: |
export SRC_ROOT=$GITHUB_WORKSPACE
./fetch-binaries.sh
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
Expand Down
83 changes: 76 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,79 @@
FROM colemancda/swift-armv7
FROM swift:5.7.1-jammy

# Copy everything
COPY . .
# Install needed packages and setup non-root user.
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
COPY .devcontainer/library-scripts/common-debian.sh /tmp/library-scripts/
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/library-scripts

# Copy Debian sysroot
#COPY ./bullseye-armv7 /workspaces/swift-armv7/bullseye-armv7
# Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="lts/*"
ENV NVM_DIR=/usr/local/share/nvm
ENV NVM_SYMLINK_CURRENT=true \
PATH=${NVM_DIR}/current/bin:${PATH}
COPY .devcontainer/library-scripts/node-debian.sh /tmp/library-scripts/
RUN bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}" \
&& rm -rf /var/lib/apt/lists/* /tmp/library-scripts

# Copy Swift runtime
#COPY ./build/swift-linux-armv7-install /workspaces/swift-armv7/build/swift-linux-armv7-install
# Install dependencies
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true && \
apt-get -q update && \
apt-get -q install -y \
wget \
curl \
build-essential \
bash \
bc \
binutils \
bzip2 \
cpio \
g++ \
gcc \
git \
gzip \
libncurses5-dev \
make \
mercurial \
whois \
patch \
perl \
python3 \
rsync \
sed \
tar \
unzip \
cmake \
gnupg \
gnupg2 \
libc6-dev \
libcurl4-openssl-dev \
libedit2 \
libgcc-9-dev \
libpython3.8 \
libsqlite3-0 \
libstdc++-9-dev \
libxml2-dev \
libz3-dev \
pkg-config \
tzdata \
zlib1g-dev \
&& rm -r /var/lib/apt/lists/*

# Copy scripts
COPY . /usr/src/swift-armv7

# Set environment
ENV SRC_ROOT=/usr/src/swift-armv7

# Generate destination.json
RUN cd $SRC_ROOT && \
$SRC_ROOT/generate-swiftpm-toolchain.sh

# Fetch Debian 11 armhf sysroot and Swift runtime
RUN cd $SRC_ROOT && \
export DOWNLOAD_SWIFT_RUNTIME=1 && \
$SRC_ROOT/fetch-binaries.sh && \
rm -rf $SRC_ROOT/build/swift-armv7.tar.gz
48 changes: 31 additions & 17 deletions fetch-binaries.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@

#!/bin/bash
set -e
source swift-define

mkdir -p ./build
mkdir -p ./downloads
mkdir -p $SRC_ROOT/build
mkdir -p $SRC_ROOT/downloads

if [[ "$DOWNLOAD_SWIFT_RUNTIME" == "1" ]]; then

# Download prebuilt Swift for Armv7
DOWNLOAD_FILE=$INSTALL_TAR
SRCURL=https://github.com/colemancda/swift-armv7/releases/download/0.5.1/swift-armv7.tar.gz
if test -f "$DOWNLOAD_FILE"; then
echo "swift-armv7.tar.gz exists"
else
echo "Download swift-armv7.tar.gz"
wget -q $SRCURL -O $DOWNLOAD_FILE
fi

# Extract Swift runtime
if [[ -d "$SWIFT_INSTALL_PREFIX" ]]; then
echo "Swift runtime exists"
else
echo "Extract Swift runtime"
rm -rf $SWIFT_INSTALL_PREFIX
mkdir -p $SWIFT_INSTALL_PREFIX
cd $SWIFT_INSTALL_PREFIX
tar -xf $INSTALL_TAR
cd $SRC_ROOT
fi
fi

# Download Debian 11 sysroot
DOWNLOAD_FILE=./downloads/bullseye-armv7.tar
DOWNLOAD_FILE=$SRC_ROOT/downloads/bullseye-armv7.tar
SRCURL=https://github.com/colemancda/swift-armv7/releases/download/0.4.0/bullseye-armv7.tar
if [[ -d "$STAGING_DIR/usr/lib" ]]; then
echo "Use existing Sysroot"
Expand All @@ -16,10 +40,10 @@ else
touch $DOWNLOAD_FILE
wget -q $SRCURL -O $DOWNLOAD_FILE
mkdir -p $STAGING_DIR
tar -xf $DOWNLOAD_FILE -C ./downloads
tar -xf $DOWNLOAD_FILE -C $SRC_ROOT/downloads
rm -rf $DOWNLOAD_FILE
cp -rf ./downloads/bullseye-armv7/* $STAGING_DIR/
rm -rf ./downloads/bullseye-armv7
cp -rf $SRC_ROOT/downloads/bullseye-armv7/* $STAGING_DIR/
rm -rf $SRC_ROOT/downloads/bullseye-armv7
fi

if [[ $OSTYPE == 'darwin'* ]]; then
Expand All @@ -33,14 +57,4 @@ if [[ $OSTYPE == 'darwin'* ]]; then
echo "Download ${SWIFT_VERSION}-osx.pkg"
wget -q $SRCURL -O $DOWNLOAD_FILE
fi

# Download prebuilt Swift for Armv7
DOWNLOAD_FILE=$INSTALL_TAR
SRCURL=https://github.com/colemancda/swift-armv7/releases/download/0.5.1/swift-armv7.tar.gz
if test -f "$DOWNLOAD_FILE"; then
echo "swift-armv7.tar.gz exists"
else
echo "Download swift-armv7.tar.gz"
wget -q $SRCURL -O $DOWNLOAD_FILE
fi
fi
14 changes: 1 addition & 13 deletions generate-xcode-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [[ $OSTYPE == 'darwin'* ]]; then
fi

# Download Swift runtime
./fetch-binaries.sh
DOWNLOAD_SWIFT_RUNTIME=1 ./fetch-binaries.sh

# Extract toolchain
if [[ -d "$XCTOOLCHAIN" ]]; then
Expand All @@ -22,17 +22,5 @@ else
cp -rf /tmp/cross-toolchain/swift-armv7.xctoolchain/* $XCTOOLCHAIN/
fi

# Extract Swift runtime
if [[ -d "$SWIFT_INSTALL_PREFIX" ]]; then
echo "Swift runtime exists"
else
echo "Extract Swift runtime"
rm -rf $SWIFT_INSTALL_PREFIX
mkdir -p $SWIFT_INSTALL_PREFIX
cd $SWIFT_INSTALL_PREFIX
tar -xf $INSTALL_TAR
cd $SRC_ROOT
fi

# Generate destination.json
./generate-swiftpm-toolchain.sh

0 comments on commit 2558c03

Please sign in to comment.