{"id":13995518,"url":"https://github.com/iainsmith/swift-docker","last_synced_at":"2025-08-21T12:30:36.438Z","repository":{"id":46335341,"uuid":"129251012","full_name":"iainsmith/swift-docker","owner":"iainsmith","description":"Build \u0026 test your swift packages using docker - `swift docker test`","archived":false,"fork":false,"pushed_at":"2020-05-01T20:43:54.000Z","size":66,"stargazers_count":196,"open_issues_count":3,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-12-06T19:32:09.374Z","etag":null,"topics":["docker","opensource","swift","swift-package-manager","swiftpm"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iainsmith.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-12T12:53:24.000Z","updated_at":"2024-01-19T22:34:51.000Z","dependencies_parsed_at":"2022-07-22T10:47:40.784Z","dependency_job_id":null,"html_url":"https://github.com/iainsmith/swift-docker","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iainsmith%2Fswift-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iainsmith%2Fswift-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iainsmith%2Fswift-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iainsmith%2Fswift-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iainsmith","download_url":"https://codeload.github.com/iainsmith/swift-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230511479,"owners_count":18237657,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","opensource","swift","swift-package-manager","swiftpm"],"created_at":"2024-08-09T14:03:27.514Z","updated_at":"2024-12-19T23:14:48.574Z","avatar_url":"https://github.com/iainsmith.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# swift-docker\n\nA command line tool for building, testing \u0026 running your swift package in a docker container.\n\n\u003cimg src=\"https://s3.eu-west-2.amazonaws.com/iainpublicgifs/swift-docker-small.gif\" width=\"500\"\u003e\n\n* [Quick start](#quick-start-for-macOS)\n* [Features](#Features)\n* [Installation](#Install-swift-docker)\n* [Usage](#Usage)\n* [Vapor](#Vapor)\n* [Docker Labels](#docker-labels)\n\n## Quick start for macOS\n\n```sh\nbrew install iainsmith/formulae/swift-docker # Install swift docker\ngit clone https://github.com/jpsim/Yams.git # Clone an example package\ncd Yams \u0026\u0026 swift test # Run the tests on your machine\nswift docker test # Run the tests in a container\nswift docker test --swift 5.1 # Check if the tests pass on swift 5.1\nswift docker write-dockerfile # Write a ./Dockerfile to the repo\n```\n\n## Features\n\n* [x] Test swift packages in one command `swift docker test`\n* [x] Use custom images - `swift docker test --image vapor/swift:latest`\n* [x] `swift docker build/test/run` commands mirror `swift build/test/run`\n* [x] Run your vapor application in a container - `swift docker vapor`\n* [x] Cached builds using docker volumes\n* [x] Use a mix of docker volumes \u0026 bind mounts for fast, small builds.\n* [x] Uses the swift docker image that matches the Package.swift manifest.\n* [x] Quickly free up space - `swift docker cleanup`\n* [x] Create a dockerfile for your project\n* [x] Quickly print a command to run the swift repl in the container - `swift docker repl`\n* [ ] Create a .dockerignore file to avoid adding .git directory to the image\n* [ ] Support multistage slim builds\n* [ ] Log output to a file\n* [ ] cmake build for running on Windows\n\n## Install swift-docker\n\nInstall with Homebrew\n```sh\nbrew install iainsmith/formulae/swift-docker\n```\n\u003cdetails\u003e\n\u003csummary\u003e\nInstall from source\n\u003c/summary\u003e\n\u003cpre\u003e\n\u003e git clone https://github.com/iainsmith/swift-docker-cli.git\n\u003e cd swift-docker\n\u003e swift build -c release --disable-sandbox\n# copy the binary to somewhere in your path.\n\u003e cp ./.build/release/swift-docker ~/bin\n\u003c/pre\u003e\n\u003c/details\u003e\n\u003c/br\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\nAnd install docker if you don't have it already\n\u003c/summary\u003e\n\n* Download the [Docker Mac App](https://www.docker.com/docker-mac).\n* Or alternatively install via homebrew `brew cask install docker`\n\u003c/details\u003e\n\n## Usage\n\n```bash\nOVERVIEW: A simple workflow for building \u0026 testing swift packages with docker\n\nRun swift docker \u003csubcommand\u003e --help for subcommand details\nReference - Offical docker images: https://hub.docker.com/_/swift\n\nExamples:\n\nswift docker test\nswift docker build -- --configuration release\nswift docker run your-executable --flag1\nswift docker vapor\n\nUSAGE: swift-docker \u003csubcommand\u003e\n\nOPTIONS:\n-h, --help              Show help information.\n\nSUBCOMMANDS:\nbuild                   Build your swift package in a docker container.\ntest                    Test your swift package in a docker container.\nrun                     Run your swift package in a docker container.\nvapor                   Run your vapor web application in a container.\nbuild-image             Build a docker image for your swift package.\nrepl                    print the command to run the swift repl in a container.\ncleanup                 Remove temporary docker images.\nwrite-dockerfile        Write a dockerfile to disk.\n```\n\n## Vapor\n\nRun `swift docker vapor` to run your vapor application in a docker container. This is significantly faster than workflows that require you\nto build a docker image as we bind the local directory into the container, and cache the build folder.\n\n* You can pass custom arguments to your application by running `swift docker vapor -- arg1 --flag1`.\n* Currently the environment is set to production \u0026 the port is set to 8080.\n* The default docker image is `swift:latest`. You can use a custom image with `swift docker vapor --image vapor/swift:latest`\n\n## Docker labels\n\nEach docker image created by `swift-docker` is tagged with two labels.\n\n```\nLABEL com.swiftdockercli.action=\"test/build\"\nLABEL com.swiftdockercli.folder=\"your-project-name\"\n```\n\nRunning `docker volume ls --filter label=com.swiftdockercli.action=test` will list volumes created by swift-docker test.\n\n## Contributing\n\nIf you have suggestions for new commands, features or bug fixes. Please raise an issue or open a PR.\n\nIf you find this tool useful in your workflow let me know on twitter [@_iains](https://twitter.com/_iains)\n\n## Credits\n\nswift-docker is built on top of\n\n* [swift-tools-support-core](https://github.com/apple/swift-tools-support-core)\n* [swift-argument-parser](https://github.com/apple/swift-argument-parser)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiainsmith%2Fswift-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiainsmith%2Fswift-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiainsmith%2Fswift-docker/lists"}