Swift is our #1 language for mobile client side development on Android and iOS. However, a growing number of developers are using Swift on the server as well. To support this, we added Docker support to our IDE. Now you can easily code server applications and run them on Docker.
We currently support the following setup
- Apple Mac OSX
- XCode 10
- Docker for Mac (latest version)
- Swift 4.1 (Swift 4.2 few weeks away)
- Just make sure Docker for Mac is installed and running
Here the steps to creating your first Hello World REST service
a. Select File|New and choose Kitura Project
b. Specify the name of the server project and choose Basic type. Then press Finish.
c. The server project is created. Open the main file and you see a basic HTTP route implementation
As you can see, the import statement is marked as having an error. This message will disappear after compiling the project
a. Select the project
Pick a project to compile. Use the project picker and select your project with Mac Docker as the target.
b. Select Docker on Mac
c. Press the compile button
When pressing the compile button, we download all docker images, sources and compile the project. Depending on your internet connection speed, this takes a while (2 - 10 minutes). However, this is only for the initial startup, after that, compilation and running the server app is immediate
d. After downloading and compiling, you see the final compilation output on the screen
First time, creating the project takes time
When you compile your server project for the first time, this will take some time (3-5 minutes), because a lot happens under the cover:
- The Swift docker file is downloaded
- The Server Framework is downloaded
- The project is compiled
b. You see the docker command for running your server!
c. Open your first server app on http://localhost:8080
Congratulation. Your first Swift server app is running on Docker
Updated about a year ago