Install swift in docker from scratch

Get Docker Image

Pull latest ubuntu image and check
docker pull ubuntu
docker images
Start ubuntu
docker run -i -t ubuntu:16.04 /bin/bash

Setup things inside Ubuntu

Ubuntu image has almost nothing installed. Lets install some stuff # https://stackoverflow.com/questions/28885137/how-to-run-wget-inside-ubuntu-docker-image
# Update apt-get itself
apt-get update

# Install wget to get swift binaries
apt-get install -y wget

# (Optional) Install your prefered text editor to edit the PATH
apt-get install -y emacs

# Install depencencies swift requires
apt-get install -y clang libicu-dev

# (Optional) Install more dependencies other libraries might need (Vapor, Kitura, etc)
apt-get install -y clang libicu-dev libcurl4-openssl-dev libssl-dev

Install swift

Lets go into some directory (create if needed)
cd /home
mkdir swift4
cd swift4
Get the latests binaries and untar. Latest links can be found in swift.org/download/#releases
wget https://swift.org/builds/swift-4.0-release/ubuntu1604/swift-4.0-RELEASE/swift-4.0-RELEASE-ubuntu16.04.tar.gz
tar -xvzf swift-4.0-RELEASE-ubuntu16.04.tar.gz
Add swift to PATH. Append the following two lines to your ~/.profile file
export SWIFT_HOME="/home/swift4/swift-4.0-RELEASE-ubuntu16.04"
export PATH=$PATH:${SWIFT_HOME}/usr/bin
Finally apply your changes
source ~/.profile
Start using swift!
swift --version
Swift version 4.0 (swift-4.0-RELEASE)
Target: x86_64-unknown-linux-gnu

More Links:

How To Use Swift Programming Language In Ubuntu Linux
How to run wget inside Ubuntu Docker image?
Swift.org/download/#releases

0 comments :

This work is licensed under BSD Zero Clause License | nacho4d ®