FrenchKit - Swift Superpowers #3

FrenchKit - Swift Superpowers #3

What swift can offer outside of Apple platforms?

This part is about tooling with developing, testing and deploying using Docker.

David Bonnet

October 08, 2019

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

27 slides
  1. using vapor 3 // POST /talks func create(_ req: Request,

    content: Talk.Create) throws -> Future<Talk> { let upload = try Storage.upload(bytes: content.imageData, fileName: content.filename, on: req) return upload.flatMap { imageUrl in let talk = Talk(name: content.name, date: content.date, imageUrl: imageUrl) return talk.save(on: req) } }
  2. using vapor 3 // POST /talks func create(_ req: Request,

    content: Talk.Create) throws -> Future<Talk> { let upload = try Storage.upload(bytes: content.imageData, fileName: content.filename, on: req) return upload.flatMap { imageUrl in let talk = Talk(name: content.name, date: content.date, imageUrl: imageUrl) return talk.save(on: req) } }
  3. https://github.com/apple/swift-corelibs-xctest XCTest // On TalksTests.swift static let allTests = [

    ("test_talkListingFromAPI", test_talkListingFromAPI), ("test_talkRetreivingFromAPI", test_talkRetreivingFromAPI), ("test_talkCreationFromAPI", test_talkCreationFromAPI) ] // On LinuxMain.swift import XCTest @testable import AppTests XCTMain([ testCase(TalksTests.allTests) ])
  4. https://github.com/apple/swift-corelibs-xctest XCTest // On TalksTests.swift static let allTests = [

    ("test_talkListingFromAPI", test_talkListingFromAPI), ("test_talkRetreivingFromAPI", test_talkRetreivingFromAPI), ("test_talkCreationFromAPI", test_talkCreationFromAPI) ] // On LinuxMain.swift import XCTest @testable import AppTests XCTMain([ testCase(TalksTests.allTests) ]) $ swift test
  5. FROM swift:5.1 RUN apt-get -qq update && apt-get install -y

    \ libssl-dev zlib1g-dev \ && rm -r /var/lib/apt/lists/* Dockerfile using vapor 3
  6. FROM swift:5.1 RUN apt-get -qq update && apt-get install -y

    \ libssl-dev zlib1g-dev \ && rm -r /var/lib/apt/lists/* Dockerfile using vapor 3 WORKDIR /app COPY . ./
  7. FROM swift:5.1 RUN apt-get -qq update && apt-get install -y

    \ libssl-dev zlib1g-dev \ && rm -r /var/lib/apt/lists/* Dockerfile using vapor 3 WORKDIR /app COPY . ./ RUN swift package resolve RUN swift package clean
  8. FROM swift:5.1 RUN apt-get -qq update && apt-get install -y

    \ libssl-dev zlib1g-dev \ && rm -r /var/lib/apt/lists/* Dockerfile using vapor 3 WORKDIR /app COPY . ./ RUN swift package resolve RUN swift package clean CMD ["swift", "test"]
  9. FROM swift:5.1 RUN apt-get -qq update && apt-get install -y

    \ libssl-dev zlib1g-dev \ && rm -r /var/lib/apt/lists/* Dockerfile using vapor 3 WORKDIR /app COPY . ./ RUN swift package resolve RUN swift package clean CMD ["swift", "test"]
  10. version: '3' services: frenchkit-api: depends_on: - postgres build: . environment:

    - DATABASE_HOSTNAME=postgres - DATABASE_PORT=5432 postgres: image: "postgres" environment: - POSTGRES_DB=frenchkit-test - POSTGRES_USER=robert - POSTGRES_PASSWORD=password docker compose
  11. version: '3' services: frenchkit-api: depends_on: - postgres build: . environment:

    - DATABASE_HOSTNAME=postgres - DATABASE_PORT=5432 postgres: image: "postgres" environment: - POSTGRES_DB=frenchkit-test - POSTGRES_USER=robert - POSTGRES_PASSWORD=password docker compose $ docker-compose build && docker-compose up
  12. $ heroku container:login heroku $ heroku container:push web $ heroku

    container:release web $ heroku create ( https://devcenter.heroku.com/articles/container-registry-and-runtime
  13. )

  14. *

More Decks by David Bonnet

Other Decks in Programming