• Stars
    star
    154
  • Rank 242,044 (Top 5 %)
  • Language
    Vim Script
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🚫 This repo is deprecated - please use the images here: https://hub.docker.com/_/swift

Build Status - Master

Swift 5 - Ubuntu Docker

This repo contains the code for generating two Docker images for Swift:

  • The ibmcom/swift-ubuntu image contains the Swift 5.0.2 RELEASE toolchain as well as the dependencies for running Kitura-based applications. Our development team uses this image for development and testing of Swift 5 applications on the Linux Ubuntu (v14.04) operating system.

  • The ibmcom/swift-ubuntu-runtime image contains only those libraries (.so files) provided by the Swift 5.0.2 RELEASE toolchain that are required to run Swift applications. Note that this image does not contain SwiftPM or any of the build tools used when compiling and linking Swift applications. Hence, the size for the ibmcom/swift-ubuntu-runtime image (~300 MB) is much smaller than that of the ibmcom/swift-ubuntu image. The ibmcom/swift-ubuntu-runtime image is ideal for provisioning your Swift application as an IBM Container on the IBM Cloud.

  • The ibmcom/swift-ubuntu-xenial and ibmcom/swift-ubuntu-xenial-runtime images follow a similar convention, but for Linux Ubuntu 16.04. These images are multi-arch so will pull down the appropriate image for your architecture. We currently offer support for amd64 and s390x architectures.

Recent updates

  1. Upgraded to the Swift 5.0.2 RELEASE binaries.
  2. Changed location of Swift binaries and libraries so they are available system wide (not just for the root user).
  3. Reduced number of layers in images.
  4. Removed system packages no longer needed.
  5. Aligned version of Ubuntu with version found in Cloud Foundry environments (v14.04).
  6. Reduced size of the Docker image.
  7. Updated Dockerfiles per guidelines in Best practices for writing Dockerfiles.
  8. Added Support for amd64 and s390x architectures of Xenial Linux Ubuntu 16.04.

Quick Start

The easiest way to get started is by using the Kitura command line tools to generate the docker files needed, and copy them over to your project. If you just want to explore our supported base images, see the next sections.

To get started with kitura init:

  1. Create a new directory, change into it and run kitura init. This will generate a project which will include two files named Dockerfile and Dockerfile-tools.
  2. Copy the Dockerfile and Dockerfile-tools files into your project's root directory (this is the directory that contains your Package.swift file and the Sources and Tests folders).
  3. Edit the Dockerfile in a text editor and replace references to your kitura init folder with the name of your project. Dockerfile-Tools has preconfigured behavior to download and compile Swift binaries and copy the executable into your application. It doesn't need editing.
  4. Run the following commands, replacing YOUR_PROJECT with the name of your project. Note: Use all lower case letters for your projects name and replace spaces with dashes.
    1. docker build -t YOUR_PROJECT-build -f Dockerfile-tools .
    2. docker run -v $PWD:/root/project -w /root/project YOUR_PROJECT-build /swift-utils/tools-utils.sh build release
    3. docker run -it -p 8090:8080 -v $PWD:/root/project -w /root/project YOUR_PROJECT-run sh -c ".build-ubuntu/release/YOUR_PROJECT"

Dockerfile-tools is responsible for downloading the Swift binaries and builds the exectuables.

The Dockerfile then copies the applications source code, and then compiled executable into the runtime image of the application. This means the large Swift binary file isn't copied into your application, and reduces the overall size of your app, meaning faster uploads and a smaller storage quota impact.

The final command runs your Docker image locally.

This was the quickest way to get started, but if you just want see explore our base images then see the following sections for detailed instructions.

ibmcom/swift-ubuntu

Pulling ibmcom/swift-ubuntu from Docker Hub

Run the following command to download the latest version of the ibmcom/swift-ubuntu image from Docker Hub:

docker pull ibmcom/swift-ubuntu:latest

Use a specific version of ibmcom/swift-ubuntu

Docker images are tagged with Swift version number. To use the Swift 5.0.2 image from Docker Hub, issue the following command:

docker pull ibmcom/swift-ubuntu:5.0.2

Using ibmcom/swift-ubuntu for development

Mount a folder on your host to your Docker container using the following command:

docker run -i -t -v <absolute path to the swift package>:/<swift package name> ibmcom/swift-ubuntu:5.0.2

After executing the above command, you will have terminal access to the Docker container (the default command for the image is /bin/bash). This will allow you to build, test, and run your Swift application in a Linux environment (Ubuntu v14.04).

Privileged mode

If you attempt to run the Swift REPL and you get the error failed to launch REPL process: process launch failed: 'A' packet returned an error: 8, then you should run your Docker container in privileged mode:

docker run --privileged -i -t ibmcom/swift-ubuntu:5.0.2

This issue is described at https://bugs.swift.org/browse/SR-54.

ibmcom/swift-ubuntu-xenial

Pulling ibmcom/swift-ubuntu-xenial from Docker Hub

Run the following command to download the latest version of the ibmcom/swift-ubuntu-xenial image from Docker Hub:

docker pull ibmcom/swift-ubuntu-xenial:latest

This image supports both amd64 and s390x architectures and will pull down the correct image based on the architecture you are using i.e. ibmcom/swift-ubuntu-xenial-amd64 or ibmcom/swift-ubuntu-xenial-s390x.

Using ibmcom/swift-ubuntu-xenial for development

Mount a folder on your host to your Docker container using the following command:

docker run -i -t -v <absolute path to the swift package>:/<swift package name> ibmcom/swift-ubuntu-xenial:latest

After executing the above command, you will have terminal access to the Docker container (the default command for the image is /bin/bash). This will allow you to build, test, and run your Swift application in a Linux environment (Ubuntu v16.04, amd64 or s390x), depending on your architecture.

Privileged mode

If you attempt to run the Swift REPL and you get the error failed to launch REPL process: process launch failed: 'A' packet returned an error: 8, then you should run your Docker container in privileged mode:

docker run --privileged -i -t ibmcom/swift-ubuntu-xenial:latest

This issue is described at https://bugs.swift.org/browse/SR-54.

ibmcom/swift-ubuntu-runtime

Pulling ibmcom/swift-ubuntu-runtime from Docker Hub

Run the following command to download the latest version of the ibmcom/swift-ubuntu-runtime image from Docker Hub:

docker pull ibmcom/swift-ubuntu-runtime:latest

Use a specific version of ibmcom/swift-ubuntu-runtime

Docker images are now tagged with Swift version number. To use the Swift 5.0.2 image from Docker Hub, issue the following command:

docker pull ibmcom/swift-ubuntu-runtime:5.0.2

Using ibmcom/swift-ubuntu-runtime

You can extend the ibmcom/swift-ubuntu-runtime image in your own Dockerfile to add your Swift application binaries (and any other dependencies you may need). For instance, the next sample Dockerfile simply adds the binaries for the Kitura-Starter application and specifies the command to start the server (total image size after adding the Kitura-Starter binaries is ~300MB):

# Builds a Docker image for running the Kitura-Starter sample application.

...

FROM ibmcom/swift-ubuntu-runtime:5.0.2
LABEL Description="Docker image for running the Kitura-Starter sample application."

USER root

# Expose default port for Kitura
EXPOSE 8080

# Binaries should have been compiled against the correct platform (i.e. Ubuntu 14.04).
RUN mkdir /Kitura-Starter
ADD .build/debug/Kitura-Starter /Kitura-Starter
ADD .build/debug/*.so /Kitura-Starter
ADD .build/debug/*.so.* /Kitura-Starter
CMD [ "sh", "-c", "/Kitura-Starter/Kitura-Starter" ]

For details on how to create an IBM Container to execute a Swift application, please see 10 Steps To Running a Swift App in an IBM Container and Running Kitura in an IBM Container.

Exposing ports in your Docker container

Exposing your server's port running in a Docker container to the host system (e.g. macOS) is quite easy using the latest version of Docker:

docker run -p <host port>:<container port> [additional options] <image name>

For example, if your Swift server is running on port 8080, and you want to make it accessible via port 9080 on the host system, run the following command:

docker run -p 9080:8080 [additional options] <image name>

Port 8080 in the container will then be mapped to port 9080 on the host system. For further details on the -p option, see the official Docker documentation.

Contributing

Improvements are very welcome! You can find more info on contributing in our contributing guidelines.

More Repositories

1

Kitura

A Swift web framework and HTTP server.
Swift
7,628
star
2

BlueSocket

Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux.
Swift
1,407
star
3

Swift-JWT

JSON Web Tokens in Swift
Swift
559
star
4

Swift-Kuery

SQL database abstraction layer
Swift
426
star
5

Swift-SMTP

Swift SMTP client
Swift
261
star
6

Swift-Kuery-ORM

An ORM for Swift, built on Codable
Swift
212
star
7

BlueCryptor

Swift cross-platform crypto library using CommonCrypto/libcrypto
Swift
191
star
8

HeliumLogger

A lightweight logging framework for Swift
Swift
176
star
9

swift-html-entities

HTML5 spec-compliant character encoder/decoder for Swift
Swift
170
star
10

BlueRSA

RSA public/private key encryption, private key signing and public key verification in Swift using the Swift Package Manager. Works on iOS, macOS, and Linux (work in progress).
Swift
132
star
11

SwiftyRequest

SwiftyRequest is an HTTP networking library built for Swift.
Swift
110
star
12

Kitura-net

Kitura networking
Swift
104
star
13

BlueSSLService

SSL/TLS Add-in for BlueSocket using Secure Transport and OpenSSL
Swift
97
star
14

Kitura-redis

Swift Redis library
Swift
95
star
15

BlueECC

Elliptic-curve cryptography for Swift
Swift
94
star
16

BlueSignals

Generic Cross Platform Signal Handler
Swift
94
star
17

Configuration

Hierarchical configuration manager for Swift applications
Swift
81
star
18

Kitura-Sample

A sample application that shows how to use various features of Kitura
Swift
81
star
19

Kitura-WebSocket

WebSocket support for Kitura
Swift
68
star
20

OpenSSL

Swift modulemaps for libSSL and libcrypto
C
61
star
21

Swift-Kuery-PostgreSQL

PostgreSQL plugin for Swift-Kuery framework
Swift
61
star
22

SwiftKafka

Swift SDK for Apache Kafka
Swift
60
star
23

KituraKit

Swift client library for using Codable routes with Kitura
Swift
59
star
24

Kitura-CouchDB

CouchDB adapter for Kitura
Swift
51
star
25

CircuitBreaker

A Swift Circuit Breaker library – Improves application stability and reliability.
Swift
47
star
26

Kitura-Credentials

A pluggable framework for validating user credentials in a Swift server using Kitura
Swift
41
star
27

Kitura-NIO

A networking library for Kitura, based on SwiftNIO
Swift
38
star
28

Kitura-OpenAPI

OpenAPI support for Kitura
Swift
37
star
29

TypeDecoder

A Swift library to allow the runtime inspection of Swift language native and complex types.
Swift
37
star
30

SwiftKueryMySQL

MySQL plugin for Swift-Kuery framework
Swift
35
star
31

Package-Builder

Build and utility scripts used for continuous integration builds for Swift Package Manager projects on the Travis CI environment
Shell
35
star
32

CCurl

Modulemap for the libcurl library
Objective-C
31
star
33

Kitura-StencilTemplateEngine

Stencil templating for Kitura
Swift
27
star
34

Kitura-Markdown

Templating engine for Kitura that uses Markdown based templates
C
26
star
35

LoggerAPI

Logger protocol
Swift
26
star
36

kitura.dev

http://www.kitura.dev
JavaScript
26
star
37

Health

An application health library for Swift.
Swift
22
star
38

Kitura-Session

A pluggable framework for managing user sessions in a Swift server using Kitura
Swift
19
star
39

Kitura-WebSocket-NIO

A SwiftNIO based implementation of WebSocket for Kitura
Swift
18
star
40

CommonCrypto

CommonCrypto Module Map
Swift
18
star
41

FileKit

Swift
17
star
42

Kitura-TemplateEngine

Kitura Template Engine protocol
Swift
16
star
43

Swift-Kuery-SQLite

An SQLite plugin for the Swift-Kuery framework
Swift
16
star
44

Kitura-CredentialsHTTP

A plugin for the Kitura-Credentials framework that authenticates using HTTP Basic and Digest authentication
Swift
16
star
45

kitura-cli

⌨️ Kitura command-line interface
Go
14
star
46

KituraContracts

A library containing type definitions shared by client and server Kitura code.
Swift
13
star
47

CZlib

Module map for Zlib library
Swift
12
star
48

CloudEnvironment

Convenience Swift package for accessing environment variables, credentials.
Swift
12
star
49

Kitura-CredentialsFacebook

A plugin for the Kitura-Credentials framework that authenticates using the Facebook web login
Swift
10
star
50

Kitura-CORS

Kitura CORS middleware
Swift
10
star
51

Kitura-Cache

Kitura cache
Swift
10
star
52

Kitura-CredentialsGoogle

A plugin for the Kitura-Credentials framework that authenticates using the Google web login
Swift
9
star
53

Swift-cfenv

Easy access to Cloud Foundry application environment for Swift Packages.
Swift
9
star
54

Kitura-Compression

Kitura compression middleware
Swift
7
star
55

CEpoll

A modulemap file and include to help Swift code use epoll on Linux
Swift
6
star
56

Kitura-WebSocket-Client

A WebSocket client based on SwiftNIO
Swift
6
star
57

Kitura-CredentialsGitHub

A plugin for the Kitura-Credentials framework that authenticates using the GitHub web login
Swift
6
star
58

Kitura-MustacheTemplateEngine

Adapter of GRMustache Template Engine to Kitura Template Engine
Swift
5
star
59

CHTTPParser

Modulemap for the http-parser library
C
5
star
60

Kitura-WebSocket-Compression

A WebSocket compression library based on SwiftNIO
Swift
4
star
61

generator-swiftserver-projects

Autogenerated Kitura projects
Shell
4
star
62

Kitura-Session-Redis

Kitura-Session store using Redis as the backing store
Swift
4
star
63

Kitura-Benchmarks

Benchmarks for Kitura
Swift
3
star
64

homebrew-kitura

Homebrew tap
Ruby
3
star
65

Kitura-CredentialsJWT

A plugin for the Kitura-Credentials framework that supports JWT authentication.
Swift
3
star
66

ShellToolKit

Utility classes to help with common system/shell actions in Swift
Swift
3
star
67

anapistula

Simple standalone web server in swift
Swift
2
star
68

CLibpq

PostgreSQL wrapper
Swift
2
star
69

CMySQL

Swift
1
star
70

Kitura-CI

Repository to hold the testing scripts for some Kitura repositories
Shell
1
star
71

Maintainers

Files relevant to Kitura project maintainers
Swift
1
star
72

StarterWebServer

A starter web server that can be used as a template for a new project
Swift
1
star