-
Notifications
You must be signed in to change notification settings - Fork 1
add vapor implementation #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
elmoritz
wants to merge
20
commits into
main
Choose a base branch
from
feature/add_vapor_implementation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
4038c1e
add vapor implementation
elmoritz fced354
add github action to publish vapor image
elmoritz 1de2024
fix build
elmoritz bdf2183
reduce Dockerfile to minimum
elmoritz 9df5a5e
rename RepositoryPattern -> Repository
elmoritz b633324
add terraform configuration
elmoritz 67f6cb4
change server to align with terraform config
elmoritz 02b22a5
Merge branch 'main' into feature/add_vapor_implementation
elmoritz bf9fb3d
update to swift version 5.9
elmoritz 05188b5
use multistage docker image
elmoritz 7a0268f
update dependencies
elmoritz cc55467
remove unecessary steps in github workflow
elmoritz 28e727d
fix multistage docker image
elmoritz 1d3b1ef
use correct swift image
elmoritz f521cae
use slim image for docker container
elmoritz a788e0a
Merge branch 'main' into feature/add_vapor_implementation
elmoritz 337c7c8
update swift
elmoritz e494755
update project
elmoritz e352507
Merge branch 'main' into feature/add_vapor_implementation
elmoritz 30722d9
update github action
elmoritz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,33 @@ | ||
| name: Publish Vapor image to ECR | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| publish: | ||
| name: Publish Vapor Image | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 | ||
|
|
||
| - name: Configure AWS credentials | ||
| uses: aws-actions/configure-aws-credentials@v1-node16 | ||
| with: | ||
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| aws-region: eu-west-1 | ||
| - name: Login to Amazon ECR | ||
| id: login-ecr | ||
| uses: aws-actions/amazon-ecr-login@261a7de32bda11ba01f4d75c4ed6caf3739e54be | ||
| - name: Build, tag, and push image to Amazon ECR | ||
| env: | ||
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
| ECR_REPOSITORY: bookstore-vapor | ||
| run: | | ||
| docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$GITHUB_SHA -t $ECR_REGISTRY/$ECR_REPOSITORY . | ||
| docker push -a $ECR_REGISTRY/$ECR_REPOSITORY | ||
| working-directory: ./bookstore-vapor |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,4 @@ | ||
| .build/ | ||
| .swiftpm/ | ||
| .derivedData | ||
| DerivedData |
This file contains hidden or 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,10 @@ | ||
| Packages | ||
| .build | ||
| xcuserdata | ||
| *.xcodeproj | ||
| DerivedData/ | ||
| .derivedData/ | ||
| .DS_Store | ||
| db.sqlite | ||
| .swiftpm | ||
| .env |
This file contains hidden or 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,82 @@ | ||
| # ================================ | ||
| # Build image | ||
| # ================================ | ||
| FROM swift:5.10-slim as build | ||
|
|
||
| # Install OS updates and, if needed, sqlite3 | ||
| RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \ | ||
| && apt-get -q update \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Set up a build area | ||
| WORKDIR /build | ||
|
|
||
| # First just resolve dependencies. | ||
| # This creates a cached layer that can be reused | ||
| # as long as your Package.swift/Package.resolved | ||
| # files do not change. | ||
| COPY ./Package.* ./ | ||
| RUN swift package resolve --skip-update \ | ||
| "$([ -f ./Package.resolved ] && echo "--force-resolved-versions" || true)" | ||
|
|
||
| # Copy entire repo into container | ||
| COPY . . | ||
|
|
||
| # Build everything, with optimizations | ||
| RUN swift build -c release --static-swift-stdlib \ | ||
| # Workaround for https://github.com/apple/swift/pull/68669 | ||
| # This can be removed as soon as 5.9.1 is released, but is harmless if left in. | ||
| -Xlinker -u -Xlinker _swift_backtrace_isThunkFunction | ||
|
|
||
| # Switch to the staging area | ||
| WORKDIR /staging | ||
|
|
||
| # Copy main executable to staging area | ||
| RUN cp "$(swift build --package-path /build -c release --show-bin-path)/Run" ./ | ||
|
|
||
| # Copy resources bundled by SPM to staging area | ||
| RUN find -L "$(swift build --package-path /build -c release --show-bin-path)/" -regex '.*\.resources$' -exec cp -Ra {} ./ \; | ||
|
|
||
| # Copy any resources from the public directory and views directory if the directories exist | ||
| # Ensure that by default, neither the directory nor any of its contents are writable. | ||
| RUN [ -d /build/Public ] && { mv /build/Public ./Public && chmod -R a-w ./Public; } || true | ||
| RUN [ -d /build/Resources ] && { mv /build/Resources ./Resources && chmod -R a-w ./Resources; } || true | ||
|
|
||
| # ================================ | ||
| # Run image | ||
| # ================================ | ||
| FROM ubuntu:jammy | ||
|
|
||
| # Make sure all system packages are up to date, and install only essential packages. | ||
| RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \ | ||
| && apt-get -q update \ | ||
| && apt-get -q install -y \ | ||
| ca-certificates \ | ||
| tzdata \ | ||
| # If your app or its dependencies import FoundationNetworking, also install `libcurl4`. | ||
| # libcurl4 \ | ||
| # If your app or its dependencies import FoundationXML, also install `libxml2`. | ||
| # libxml2 \ | ||
| && rm -r /var/lib/apt/lists/* | ||
|
|
||
| # Create a vapor user and group with /app as its home directory | ||
| RUN useradd --user-group --create-home --system --skel /dev/null --home-dir /app vapor | ||
|
|
||
| # Switch to the new home directory | ||
| WORKDIR /app | ||
|
|
||
| # Copy built executable and any staged resources from builder | ||
| COPY --from=build --chown=vapor:vapor /staging /app | ||
|
|
||
| # Provide configuration needed by the built-in crash reporter and some sensible default behaviors. | ||
| ENV SWIFT_ROOT=/usr SWIFT_BACKTRACE=enable=yes,sanitize=yes,threads=all,images=all,interactive=no | ||
|
|
||
| # Ensure all further commands run as the vapor user | ||
| USER vapor:vapor | ||
|
|
||
| # Let Docker bind to port 8080 | ||
| EXPOSE 8080 | ||
|
|
||
| # Start the Vapor service when the image is run, default to listening on 8080 in production environment | ||
| ENTRYPOINT ["./Run"] | ||
| CMD ["serve", "--env", "production", "--hostname", "0.0.0.0", "--port", "8080"] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.