How I’m dockerizing Swift web apps in serve.swifton.me 🍸
In the beginning, there was Swift…
Some of you might know that I’ve been working on getting Swift to run on Linux servers ever since it has been open sourced.
IBM made a pretty good P.o.C of what can be achieved by executing Swift code on the server, and my little project Swifton.me has also had a decent start. In this blogpost I’ll show you how to deploy a basic app to serve.swifton.me.
This service comes for free but also doesn’t bring any guarantees. 🍸
… and now there is Swifton.me
Swifton.me is a service to use the Swift programming language in the cloud. It’s a service written by me and it’s open source. I’m using Let’s Encrypt (thanks guys, you rock 🚀) to issue its SSL certificates.
For the impatient ones, just try out this One-click url and see how to deploy a Web App in just one step, without even installing anything on your machine.
If you’d like to know more, just keep on reading and make sure you’ve got NPM installed, you’ll need it 😉 (in case you want to deploy using the CLI).
Keeping your Swift web-apps under control
As soon as you’ve got your NPM ready (I’d recommend installing Node.js using NVM in case you haven’t done yet), just install it globally using:
Deploying Swift Apps to Swifton.me in just one step:
If you’re heading over to the url the CLI shows you (in this demo it was lonely-curie.serve.swifton.me) then you’ll be greeted with a loading indicator until the App has finished booting up. This should take under till slightly above a minute, depending on how complex your App is.
By now you’re having a fully-functional Swift Web App deployed on serve.swifton.me. You might have noticed that it wasn’t necessary to create a user account or authenticate via any other way. Authentication is on the roadmap and will be implemented in the future, right now you have to take care of and manager your container Id by yourself. Once this id is lost you’ll never gain control over your App back. Once this id get’s into the wrong hand, anybody might delete your App or retrieve its logs.
This is an important PA
When using the One-click deployment, your App’s container Id will be appended to the URL, prefixed with a # (hash). Please do not lose or share this container Id with anyone. If you give it away, anybody might gain access to your App. You can, however, share the URL, but please remove everything including the # when handing the URL to anybody else. And please also store your container Id somewhere safe.
The service features a hand full of RESTful services (go here for a comprehensive list of our RESTful APIs). As you can see it’s easily possible to stream your App’s logs to your browser:
The whole Swifton.me project is still at it’s very beginning but it’s already working pretty well. I’d really like to invite you, write Apps and deploy them, bring the service to it’s limits (shouldn’t be too heard, eh?), bring the whole infrastructure down and, ideally, contribute.
More in-depth information? Get it here…
So what does Swifton.me do? Swifton.me consists of multiple micro services for deploying and keeping Web Apps written in Swift alive and on the server.
Swifton.me consists of a lot more, but those are the services a user will commonly interact with:
code.swifton.me A node.js based app providing an editor to code in Swift and view the compiler output.
run.swifton.me A node.js compiler backend, compiling code in an isolated dockerized environment end returning the compiler’s output.
serve.swifton.me A node.js application platform, checking out Swift code (using Git), compiling and running it. Ideally for running Swift web-apps e.g. using https://github.com/kylef/Curassow-example-helloworld.
That’s it for now, but I’m sure there’s still plenty of cool stuff to come.
Originally published at blog.kida.io.