-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch from Render.com to Kamal on private server.
Dockerize the website and test app. Upgrade to Rails 7.1. Fix show_exceptions setting for Rails 7.1. Fix ransack for rails 7.1. Fix simplecov for Rails 7.1. Fix issue where simplecov is imported in non-test processes. Add solid_queue to test it out in case we need scheduled jobs in the website. Refactor GH action pipeline to deploy using Kamal to private server. Upgrade some actions to fix some node 16 errors.
- Loading branch information
1 parent
d7ad8d4
commit bba3c66
Showing
32 changed files
with
728 additions
and
226 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 |
---|---|---|
|
@@ -4,10 +4,8 @@ jobs: | |
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Install Ruby/Gems | ||
uses: ruby/setup-ruby@v1 | ||
- uses: actions/checkout@v4 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
- name: Run code checks | ||
|
@@ -19,7 +17,7 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
ruby: [2.7.5, 3.0.6, 3.1.4, 3.2.2] | ||
rails: [6.0.6, 6.1.7, 7.0.4] | ||
rails: [6.0.6, 6.1.7, 7.0.4, 7.1.3] | ||
exclude: | ||
- ruby: 3.1.4 | ||
rails: 6.0.6 | ||
|
@@ -29,12 +27,10 @@ jobs: | |
RAILS_VERSION: ${{ matrix.rails }} | ||
CUSTOM_RUBY_VERSION: ${{ matrix.ruby }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
- name: Remove `Gemfile.lock` because this is a matrix job | ||
run: rm Gemfile.lock | ||
- name: Install Ruby/Gems | ||
uses: ruby/setup-ruby@v1 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby }} | ||
bundler-cache: true | ||
|
@@ -44,7 +40,7 @@ jobs: | |
run: BACKTRACE=1 bin/rails test | ||
- name: Check if coverage LCOV file exists | ||
id: lcov_exists | ||
uses: andstor/file-existence-action@v2 | ||
uses: andstor/file-existence-action@v3 | ||
with: | ||
files: coverage/lcov.info | ||
- name: Submit coverage to `coveralls.io` if LCOV file exists | ||
|
@@ -57,23 +53,42 @@ jobs: | |
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') | ||
steps: | ||
- name: Trigger render.com deploy hook | ||
run: curl -X POST '${{ secrets.RENDER_COM_DEPLOY_HOOK }}' | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
- uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.APPSERVER_DEPLOY_SSH_KEY }} | ||
- name: Setup appserver known_hosts | ||
run: cat config/appserver.known_hosts >> ~/.ssh/known_hosts | ||
- name: Set up Docker Buildx for cache | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Expose GitHub Runtime for cache | ||
uses: crazy-max/ghaction-github-runtime@v3 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
- name: Build and deploy using Kamal | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: bundle exec kamal deploy | ||
release: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.ref, 'refs/tags/') | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Ensure latest tag is fetched | ||
run: git fetch --unshallow --prune --tags --force | ||
- name: Install Ruby/Gems | ||
uses: ruby/setup-ruby@v1 | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
- name: Build the gem | ||
run: gem build rest_framework.gemspec -o rest_framework.gem | ||
- name: Display VERSION | ||
run: cat VERSION | ||
- name: Push to RubyGems | ||
env: | ||
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | ||
|
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 |
---|---|---|
@@ -1 +1 @@ | ||
7.0.4 | ||
7.1.3 |
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,31 @@ | ||
FROM ruby:3.2.2-bookworm as base | ||
LABEL org.opencontainers.image.source=https://github.com/gregschmit/rails-rest-framework | ||
WORKDIR /app | ||
ENV BUNDLE_PATH="/usr/local/bundle" | ||
ENV RAILS_ENV="production" | ||
ENV DISABLE_DATABASE_ENVIRONMENT_CHECK="1" | ||
|
||
# Throw-away build stage to reduce size of final image | ||
FROM base as build | ||
|
||
# Setup application gems. | ||
COPY .ruby-version .rails-version rest_framework.gemspec Gemfile Gemfile.lock ./ | ||
RUN bundle install | ||
|
||
# Setup application. | ||
COPY . . | ||
RUN bin/rails runner "RESTFramework::Version.stamp_version" | ||
RUN bin/rails db:reset | ||
RUN LOGS=all bin/rails log:clear tmp:clear | ||
RUN rm -rf ~/.bundle "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git | ||
RUN rm -rf .git | ||
|
||
# Final stage for app image. | ||
FROM base | ||
|
||
# Copy built artifacts: gems, application. | ||
COPY --from=build /usr/local/bundle /usr/local/bundle | ||
COPY --from=build /app /app | ||
|
||
EXPOSE 3000 | ||
CMD ["bin/rails", "server"] |
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
Oops, something went wrong.