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

Server-Side Swift (iOSDevUK 7)

Claus Höfele
September 05, 2017

Server-Side Swift (iOSDevUK 7)

What app developers should know about server-side Swift

Featured projects:
AlexaSkillsKit (https://github.com/choefele/AlexaSkillsKit)
swift-server-app (https://github.com/choefele/swift-server-app)
swift-lambda-app (https://github.com/choefele/swift-lambda-app)

Claus Höfele

September 05, 2017
Tweet

More Decks by Claus Höfele

Other Decks in Programming

Transcript

  1. AlexaSkillsKit • Swift library to develop custom skills for Amazon

    Alexa • Cross-platform Swift • Development: macOS • Deployment: Linux
  2. swiftenv swiftenv [--version] <command> install Installs a version of Swift

    version Displays the current active Swift version versions Lists all installed Swift versions …
  3. Docker Usage Cont’d #!/bin/bash set -e SWIFT_VERSION=$(<.swift-version) docker run \

    --rm \ --volume "$(pwd):/app" \ --workdir /app \ swift:$SWIFT_VERSION \ swift test --build-path /.build
  4. Docker Usage Cont’d #!/bin/bash set -e SWIFT_VERSION=$(<.swift-version) docker run \

    --rm \ --volume "$(pwd):/app" \ --workdir /app \ swift:$SWIFT_VERSION \ swift test --build-path /.build
  5. Docker Usage Cont’d #!/bin/bash set -e SWIFT_VERSION=$(<.swift-version) docker run \

    --rm \ --volume "$(pwd):/app" \ --workdir /app \ swift:$SWIFT_VERSION \ swift test --build-path /.build
  6. Travis CI matrix: include: - os: osx osx_image: xcode8.3 sudo:

    required - os: linux dist: trusty sudo: required - os: linux dist: trusty sudo: required services: docker install: … script: … macOS Linux Docker (Linux)
  7. Dockerfile FROM swift:3.1 WORKDIR /app RUN apt-get update && apt-get

    install -y \ libssl-dev \ && rm -rf /var/lib/apt/lists/* COPY Package.swift ./ RUN swift package fetch; exit 0 EXPOSE 8090 COPY Sources ./Sources COPY Tests ./Tests RUN swift test CMD ./.build/debug/SwiftServer
  8. Dockerfile FROM swift:3.1 WORKDIR /app RUN apt-get update && apt-get

    install -y \ libssl-dev \ && rm -rf /var/lib/apt/lists/* COPY Package.swift ./ RUN swift package fetch; exit 0 EXPOSE 8090 COPY Sources ./Sources COPY Tests ./Tests RUN swift test CMD ./.build/debug/SwiftServer
  9. Dockerfile FROM swift:3.1 WORKDIR /app RUN apt-get update && apt-get

    install -y \ libssl-dev \ && rm -rf /var/lib/apt/lists/* COPY Package.swift ./ RUN swift package fetch; exit 0 EXPOSE 8090 COPY Sources ./Sources COPY Tests ./Tests RUN swift test CMD ./.build/debug/SwiftServer
  10. Dockerfile FROM swift:3.1 WORKDIR /app RUN apt-get update && apt-get

    install -y \ libssl-dev \ && rm -rf /var/lib/apt/lists/* COPY Package.swift ./ RUN swift package fetch; exit 0 EXPOSE 8090 COPY Sources ./Sources COPY Tests ./Tests RUN swift test CMD ./.build/debug/SwiftServer
  11. Dockerfile FROM swift:3.1 WORKDIR /app RUN apt-get update && apt-get

    install -y \ libssl-dev \ && rm -rf /var/lib/apt/lists/* COPY Package.swift ./ RUN swift package fetch; exit 0 EXPOSE 8090 COPY Sources ./Sources COPY Tests ./Tests RUN swift test CMD ./.build/debug/SwiftServer
  12. AWS Lambda • Function as a Service, “Serverless” Architecture •

    Only pay for execution time • Event based • Stateless • Less server management