一个命令行工具,用于在 Docker 容器中构建、测试和运行你的 Swift 包。
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
命令与 swift build/test/run
命令类似swift docker vapor
swift docker cleanup
swift docker repl
使用 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.
运行 swift docker vapor
在 Docker 容器中运行你的 Vapor 应用。这比需要你构建 Docker 镜像的工作流程快得多,因为我们将本地目录绑定到容器中,并缓存构建文件夹。
swift docker vapor -- arg1 --flag1
向你的应用程序传递自定义参数。swift:latest
。 你可以使用自定义镜像,通过 swift docker vapor --image vapor/swift:latest
每个由 swift-docker
创建的 Docker 镜像都带有两个标签。
LABEL com.swiftdockercli.action="test/build"
LABEL com.swiftdockercli.folder="your-project-name"
运行 docker volume ls --filter label=com.swiftdockercli.action=test
将列出由 swift-docker test 创建的 Volumes。
如果你对新命令、功能或错误修复有建议,请提出 issue 或打开 PR。
如果你觉得这个工具对你的工作流程有用,请在 Twitter 上告诉我 @_iains
swift-docker 构建于以下组件之上: