Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift in Docker

Johnlin
February 07, 2017

Swift in Docker

Johnlin

February 07, 2017
Tweet

More Decks by Johnlin

Other Decks in Programming

Transcript

  1. Swift in Docker • https://github.com/swiftdocker/docker-swift • docker run --cap-add sys_ptrace

    -it --rm swift swift
 ՄҎࣥߦ REPL • Swift REPL Ҽҝ༻౸ ptraceɼॴҎधཁֹ֎తᒟݶ
  2. ݐஔ Package • docker run -v `pwd`/:/docker-swift -w /docker- swift

    --rm swift swift package init
 㗞ੜ Package ૬᮫䈕Ҋ • echo 'print("hello docker")' >> Sources/ main.swift
 ࡏࣥߦ䈕࠷ޙՃ্Ұݸprint hello docker
  3. ݐஔ Package • docker run -v `pwd`/:/docker-swift -w /docker- swift

    --rm swift swift build
 ݐஔ Package • docker run -v `pwd`/:/docker-swift -w /docker- swift --rm swift .build/debug/docker-swift
 ࣥߦhello docker
  4. Update docker file FROM ibmcom/swift-ubuntu:latest EXPOSE 8080 RUN mkdir /root/Kitura-Starter

    ADD Sources /root/Kitura-Starter ADD Package.swift /root/Kitura-Starter ADD LICENSE /root/Kitura-Starter ADD .swift-version /root/Kitura-Starter RUN cd /root/Kitura-Starter && swift build USER root CMD [ "sh", "-c", "cd /root/Kitura-Starter && .build/debug/Kitura-Starter" ]
  5. Update docker file FROM swift:3.0.2 EXPOSE 8080 RUN mkdir /root/Kitura-Starter

    ADD Sources /root/Kitura-Starter ADD Package.swift /root/Kitura-Starter ADD LICENSE /root/Kitura-Starter ADD .swift-version /root/Kitura-Starter RUN apt update RUN apt-get install -y libssl-dev WORKDIR /root/Kitura-Starter RUN swift package update RUN swift build USER root CMD [ "sh", "-c", "cd /root/Kitura-Starter && .build/debug/Kitura-Starter" ]
  6. Q&A