Server app with Swift and Docker
MIT License
Template to build a server app with Swift and Docker
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer/
swiftenv
(optional since Swift built into Xcode 8 is the currently the latest version)swiftenv
via Homebrew
swiftenv rehash
, swiftenv install <version>
(see .swift-version
)swift build
in root folder, wait until dependencies have been downloaded and server has been builtdocker-compose -f docker-compose-dev.yml up
./.build/debug/SwiftServer
curl http://localhost:8090/ping
curl -X POST localhost:8090/items
, curl http://localhost:8090/items
swift test
swift package fetch
in root folder to update dependenciesswift package generate-xcodeproj
docker-compose -f docker-compose-dev.yml up
SwiftServer.xcodeproj
in Xcode and Run SwiftServer
schemecurl http://localhost:8090/ping
curl -X POST localhost:8090/items
, curl http://localhost:8090/items
docker-compose -f docker-compose-ci.yml build
; tests a run as part of the build processdocker-compose -f docker-compose-ci.yml up [-d]
(stop: docker-compose down [-v]
, logs: docker-compose logs -f
)curl http://localhost:8090/ping
curl -X POST localhost:8090/items
, curl http://localhost:8090/items
mongo
to database serverdocker-compose run --rm db mongo mongodb://db
to connect to databaseuse test
, db.items.insert({})
, db.items.find()
to create sample datadocker inspect -f "{{json .Mounts}}" swiftserver_db_1
to find out mount pointdocker volume ls -f dangling=true
to find orphaned managed volumesdocker volume rm $(docker volume ls -qf dangling=true)
to remove orphaned volumesdocker-machine create --driver digitalocean --digitalocean-access-token <token> SwiftServer
eval "$(docker-machine env SwiftServer)"
, eval "$(docker-machine env -u)"
docker-machine ssh SwiftServer
to ssh into new machinehttps://github.com/bhurlow/machine-share
docker compose -f docker-compose-prod.yml up
to start servicesnewman
with npm install newman --global
./run-integration-tests.sh