Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kylef/heroku-buildpack-swift
Heroku build pack for Swift
https://github.com/kylef/heroku-buildpack-swift
Last synced: about 2 months ago
JSON representation
Heroku build pack for Swift
- Host: GitHub
- URL: https://github.com/kylef/heroku-buildpack-swift
- Owner: kylef
- License: bsd-3-clause
- Archived: true
- Fork: true (cloudfoundry-community/swift-buildpack)
- Created: 2015-12-04T16:49:32.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-10-24T21:10:38.000Z (about 3 years ago)
- Last Synced: 2024-08-07T22:35:36.840Z (5 months ago)
- Language: Shell
- Homepage:
- Size: 36.1 KB
- Stars: 508
- Watchers: 15
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Heroku buildpack: swift
This buildpack is not recommended for use. Instead consider using [Heroku's container runtime](https://devcenter.heroku.com/articles/container-registry-and-runtime) along with the [Swift container images](https://swift.org/download/).
For example a Dockerfile:
```dockerfile
FROM docker.io/swift:5.5 as buildWORKDIR /usr/src/app
COPY Package.swift Package.resolved ./
COPY Sources Sources
COPY Tests Tests
RUN swift build --configuration release
RUN swift test --configuration releaseFROM docker.io/swift:5.5-slim
# Copy the build executable target (named in Package.swift)
COPY --from=build /usr/src/app/.build/release/server .
CMD ./server $PORT
```Build and push the image to Heroku's registry:
```shell
$ heroku container:push web
```Then release the image:
```shell
$ heroku container:release web
```## Buildpack Usage
For historical purposes, below are the usage for the buildpack. Although its use is discouraged.
Example usage:
```shell
$ ls
Procfile Package.swift Sources$ heroku create --buildpack kyle/swift
$ git push heroku master
remote: -----> Swift app detected
remote: -----> Installing Swift 4.1
remote: -----> Installing clang-3.7.0
remote: -----> Building Package
remote: -----> Copying binaries to 'bin'
```You can also add it to upcoming builds of an existing application:
```shell
$ heroku buildpacks:set kyle/swift
```The buildpack will detect your app as Swift if it has a `Package.swift` file in
the root.### Procfile
Using the Procfile, you can set the process to run for your web server. Any
binaries built from your Swift source using swift package manager will
be placed in your $PATH.```swift
web: HelloWorld --workers 3 --bind 0.0.0.0:$PORT
```### Specify a Swift version
You can also customise the version of Swift used with a `.swift-version` file
in your repository:```shell
$ cat .swift-version
4.1
```The `.swift-version` file is completely compatible with
[swiftenv](http://github.com/kylef/swiftenv).**NOTE**: *Since there are frequent Swift language changes, it's advised that
you pin to your Swift version.*### Hooks
You can place custom scripts to be ran before and after compiling your Swift
source code inside the following files in your repository:- `bin/pre_compile`
- `bin/post_compile`This is useful if you would need to install any other dependencies.
### Using the latest buildpack code
The `kyle/swift` buildpack from the [Heroku Registry](https://devcenter.heroku.com/articles/buildpack-registry) represents the latest stable version of the buildpack. If you'd like to use the latest buildpack code from this Github repository, you can set your buildpack to the GitHub URL:
```shell
$ heroku buildpacks:set https://github.com/kylef/heroku-buildpack-swift
```