Build & test your swift packages using docker - `swift docker test`
A command line tool for building, testing & running your swift package in a docker container.
brew install iainsmith/formulae/swift-docker # Install swift docker
git clone https://github.com/jpsim/Yams.git # Clone an example package
cd Yams && swift test # Run the tests on your machine
swift docker test # Run the tests in a container
swift docker test --swift 5.1 # Check if the tests pass on swift 5.1
swift docker write-dockerfile # Write a ./Dockerfile to the repo
swift docker test
swift docker test --image vapor/swift:latest
swift docker build/test/run
commands mirror swift build/test/run
swift docker vapor
swift docker cleanup
swift docker repl
Install with Homebrew
brew install iainsmith/formulae/swift-docker
> git clone https://github.com/iainsmith/swift-docker-cli.git > cd swift-docker > swift build -c release --disable-sandbox # copy the binary to somewhere in your path. > cp ./.build/release/swift-docker ~/bin
brew cask install docker
OVERVIEW: A simple workflow for building & testing swift packages with docker
Run swift docker <subcommand> --help for subcommand details
Reference - Offical docker images: https://hub.docker.com/_/swift
Examples:
swift docker test
swift docker build -- --configuration release
swift docker run your-executable --flag1
swift docker vapor
USAGE: swift-docker <subcommand>
OPTIONS:
-h, --help Show help information.
SUBCOMMANDS:
build Build your swift package in a docker container.
test Test your swift package in a docker container.
run Run your swift package in a docker container.
vapor Run your vapor web application in a container.
build-image Build a docker image for your swift package.
repl print the command to run the swift repl in a container.
cleanup Remove temporary docker images.
write-dockerfile Write a dockerfile to disk.
Run swift docker vapor
to run your vapor application in a docker container. This is significantly faster than workflows that require you
to build a docker image as we bind the local directory into the container, and cache the build folder.
swift docker vapor -- arg1 --flag1
.swift:latest
. You can use a custom image with swift docker vapor --image vapor/swift:latest
Each docker image created by swift-docker
is tagged with two labels.
LABEL com.swiftdockercli.action="test/build"
LABEL com.swiftdockercli.folder="your-project-name"
Running docker volume ls --filter label=com.swiftdockercli.action=test
will list volumes created by swift-docker test.
If you have suggestions for new commands, features or bug fixes. Please raise an issue or open a PR.
If you find this tool useful in your workflow let me know on twitter @_iains
swift-docker is built on top of