-
-
Notifications
You must be signed in to change notification settings - Fork 618
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Dockerfile To simplify building on Linux: ```console docker build -t sourcery-image . docker run sourcery-image sourcery --help ``` I've kept the resulting Docker image small(-ish) at the expense of probably removing some useful functionality. I haven't tested this thoroughly but I'll leave it to other contributors can expand this as needed. * Simplfy build flags Since the runtime image is also Swift. * Add CI job to build and publish docker images to GitHub Packages Will run on commits to the `master` branch and tags.
- Loading branch information
Showing
3 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Docker | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Extract DOCKER_TAG using tag name | ||
if: startsWith(github.ref, 'refs/tags/') | ||
run: | | ||
echo "DOCKER_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV | ||
- name: Use default DOCKER_TAG | ||
if: startsWith(github.ref, 'refs/tags/') != true | ||
run: | | ||
echo "DOCKER_TAG=latest" >> $GITHUB_ENV | ||
- name: Set lowercase repository name | ||
run: | | ||
echo "REPOSITORY_LC=${REPOSITORY,,}" >>${GITHUB_ENV} | ||
env: | ||
REPOSITORY: '${{ github.repository }}' | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to GitHub registry | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: ghcr.io | ||
|
||
- uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
tags: ghcr.io/${{ env.REPOSITORY_LC }}:${{ env.DOCKER_TAG }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
ARG BUILDER_IMAGE=swift:5.9-jammy | ||
ARG RUNTIME_IMAGE=swift:5.9-jammy-slim | ||
|
||
# Builder image | ||
FROM ${BUILDER_IMAGE} AS builder | ||
RUN apt-get update && apt-get install -y \ | ||
build-essential \ | ||
libffi-dev \ | ||
libncurses5-dev \ | ||
libsqlite3-dev \ | ||
&& rm -r /var/lib/apt/lists/* | ||
WORKDIR /workdir/ | ||
COPY Sourcery Sourcery/ | ||
COPY SourceryExecutable SourceryExecutable/ | ||
COPY SourceryFramework SourceryFramework/ | ||
COPY SourceryJS SourceryJS/ | ||
COPY SourceryRuntime SourceryRuntime/ | ||
COPY SourceryStencil SourceryStencil/ | ||
COPY SourcerySwift SourcerySwift/ | ||
COPY SourceryTests SourceryTests/ | ||
COPY SourceryUtils SourceryUtils/ | ||
COPY Plugins Plugins/ | ||
COPY Templates Templates/ | ||
COPY Tests Tests/ | ||
COPY Package.* ./ | ||
|
||
RUN swift package update | ||
ARG SWIFT_FLAGS="-c release" | ||
RUN swift build $SWIFT_FLAGS --product sourcery | ||
RUN mv `swift build $SWIFT_FLAGS --show-bin-path`/sourcery /usr/bin | ||
RUN sourcery --version | ||
|
||
# Runtime image | ||
FROM ${RUNTIME_IMAGE} | ||
LABEL org.opencontainers.image.source https://github.com/krzysztofzablocki/Sourcery | ||
RUN apt-get update && apt-get install -y \ | ||
libcurl4 \ | ||
libsqlite3-0 \ | ||
libxml2 \ | ||
&& rm -r /var/lib/apt/lists/* | ||
COPY --from=builder /usr/bin/sourcery /usr/bin | ||
|
||
RUN sourcery --version | ||
|
||
CMD ["sourcery"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters