Code Monkey home page Code Monkey logo

s2i-swift-1's Introduction

Swift source-to-image

Swift logo

OCP logo

This repository contains the source for building Swift applications as reproducible Docker images using source-to-image.

For more information about using these images with OpenShift, please see the official OpenShift Documentation.

For more information about the open source Swift programming language goto the Swift website.

Below you can read how to build and how to use. FYI, you don't have to build this repo, you can use a prebuilt image - I'll try to keep updated versions of it available on docker hub.

docker hub stats

Versions available

Swift versions available

  • Swift 3.0

OS versions available

  • ubuntu14 = Ubuntu 14.04
  • centos7 = CentOS 7 (IN WORK)
  • rhel7 = RHEL 7 (IN WORK)

Using this image

You'll need to have the s2i tool.

Find and get the image you want (VERSION and PLATFORM)

$ docker search dudash/swift
$ docker pull dudash/swift-VER-PLATFORM

Using with the local test app

Use the s2i tool to build the final image that contains your application code - in this case the test app provided in this repo:

$ git clone https://github.com/dudash/s2i-swift.git
$ s2i build ./3.0/test/test-app/ dudash/swift-30-ubuntu14 swift-test-app
  • ./3.0/test/test-app/ is the top directory of the source code (replace test path with your code's path).
  • openshift/swift-30-ubuntu14 is the name of the s2i builder image created by make build above (including the repo).
  • swift-test-app is the name of the new application image that contains your app built from source code.

Finally, run your application in a container to see that it worked (swift-test-app is the image you created using s2i):

$ docker run swift-test-app

Using with github projects

Use the s2i tool to build the final image that contains your application code

  • Hello swift from github example
$ s2i build https://github.com/dudash/openshiftexamples-simpleswift.git dudash/swift-30-ubuntu14 hello-swift
$ docker run hello-swift
  • Apple's swift example package-dealer on github (with logging set to 5):
$ s2i build --loglevel 5 https://github.com/apple/example-package-dealer.git dudash/swift-30-ubuntu14 package-dealer
$ docker run package-dealer

How to structure your code

Package Manager Builds

You can build swift apps for linux that leverage Swift Package Manager. The build process assumes you will have a Package.swift at the top level describing your app and it's dependencies. Your app's Swift code should be located in a "Sources" directory. Local package dependencies should be placed in a directory called "LocalPackages" (see the test app as an example).

Straight Source Builds

You can just point s2i to a folder of swift files and it will compile them into an executable. Note you will need a main.swift file for Swift to execute.

Using in Open Shift

You can install the S2I Swift images from with templates:

$ oc create -n openshift -f https://raw.githubusercontent.com/dudash/s2i-swift/master/openshift-resources/swift-all-ubuntu14-imagestreamlist.json

Note: Drop the -n openshift if you don't have admin rights... or ask your admin to create it.

โš ๏ธ OpenShift is expects your conatiners to keep running. So some of the above examples are not the best to try in Open Shift. If you don't have your own code and need an example, try this one: Hello Kitura

Building this repo

Build

To prepare the s2i builder image (for building on Ubuntu 14.04 & Swift 3.0):

$ git clone https://github.com/dudash/s2i-swift.git
$ cd s2i-swift
$ make build VERSION=3.0 TARGET=ubuntu14

Repo organization

**[swift-version]**: Dockerfile to build container images from
**[swift-version]/test/test-app**: Sample application used for tests
**hack/**: Folder containing scripts which are responsible for the build and test actions performed by the Makefile
**s2i/**: Build scripts which will be injected into the builder image and executed during application source code builds

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.