diff --git a/.github/workflows/deploy-to-fly.yml b/.github/workflows/deploy-to-fly.yml deleted file mode 100644 index a2a79d6..0000000 --- a/.github/workflows/deploy-to-fly.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Deploy to Fly -on: - push: - branches: - - main -env: - FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} -jobs: - deploy: - name: Deploy app - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: superfly/flyctl-actions/setup-flyctl@master - - run: flyctl deploy diff --git a/README.md b/README.md index 36b401f..9efe20b 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ the [Grape framework](https://github.com/ruby-grape/grape). - Standard security headers with [`secure_headers`](https://github.com/github/secure_headers). - Monitoring and alerting with [Sentry](https://sentry.io) and[Prometheus](https://prometheus.io). - Comprehensive [RSpec](https://rspec.info/) test suite and code coverage. -- Easy [fly.io](https://fly.io/) deployment. ## Running @@ -68,64 +67,6 @@ documentation. ## Production -### fly.io - -You can easily deploy to fly.io with a few steps. - -- Login and create a new fly.io application. - -``` -flyctl auth login -flyctl launch -``` - -- Create a new free tier PostgreSQL database. - -``` -flyctl postgres create -flyctl postgres attach --app -db -``` - -- Generate a key pair for use with fly.io JWT authentication. - - NOTE: _Ensure that you keep the private key secret and out of your git repository!_ - -``` -ssh-keygen -t rsa -b 4096 -m PEM -f fly_jwtRS256.key -openssl rsa -in fly_jwtRS256.key -pubout -outform PEM -out fly_jwtRS256.key.pub -``` - -- Set necessary [environment variables](https://fly.io/docs/reference/secrets/#setting-secrets) using `flyctl`, for example `flyctl secrets set RACK_ENV=production`. You should at least set the secrets below. - -``` -RACK_ENV=production -GRAPE_BOILERPLATE_SETTINGS__JWT__PRIVATE_KEY= -GRAPE_BOILERPLATE_SETTINGS__JWT__PUBLIC_KEY= -``` - -- Deploy your code to your new fly.io app. - -``` -flyctl deploy -``` - -- Create an example user. - -``` -flyctl ssh console -cd /usr/src/app -bundle exec rake users:create -``` - -- Or alternatively, seed your database with a couple of users and widgets for testing. - -``` -flyctl ssh console -cd /usr/src/app -bundle exec rake db:seed -``` - -- Use your new API! - ### Sentry You can enable [Sentry](https://sentry.io/) for your API by setting `sentry.enabled` in your settings file(s). @@ -156,25 +97,6 @@ prometheus: _Note_: Prometheus metrics should not be exposed publicly! Please ensure you know what you're doing before enabling this feature in your environment. -#### Want to play around? - -There's an instance of this API running at https://grape-api-boilerplate.fly.dev/. If it doesn't respond right -away, give it a few seconds to awake from the free tier hibernation. - -``` -# Hello world! -curl https://grape-api-boilerplate.fly.dev/api/v1/hello | jq . - -# Authenticate with the test user. -token=$(curl -XPOST \ - -H "Content-Type:application/json" \ - -d '{"username":"grape_user","password":"grape_user1"}' \ - https://grape-api-boilerplate.fly.dev/api/login | jq -r '.token') - -curl -H "Authorization: Bearer ${token}" \ - https://grape-api-boilerplate.fly.dev/api/v1/widget | jq . -``` - ### Docker Build a production ready image with the [`Dockerfile`](Dockerfile) and deploy to your favorite platform. diff --git a/Rakefile b/Rakefile index eeeca21..966b7a2 100755 --- a/Rakefile +++ b/Rakefile @@ -19,7 +19,7 @@ task :environment do # rubocop:disable Rake/Desc require File.expand_path('config/environment.rb', __dir__) end -# Don't bomb when running Rake tasks on fly.io. +# Don't bomb when running Rake tasks on something like fly.io. begin # RSpec require 'rspec/core' diff --git a/fly.toml b/fly.toml deleted file mode 100644 index 910b015..0000000 --- a/fly.toml +++ /dev/null @@ -1,36 +0,0 @@ -# fly.toml app configuration file generated for grape-api-boilerplate on 2023-08-10T11:41:10-06:00 -# -# See https://fly.io/docs/reference/configuration/ for information about how to use this file. -# - -app = "grape-api-boilerplate" -kill_signal = "SIGINT" -kill_timeout = "5s" -[processes] - app = "/bin/sh -c 'bundle exec rake db:migrate && tini -- bundle exec puma -C config/puma/puma.rb'" - -[experimental] - auto_rollback = true - -[[services]] - protocol = "tcp" - internal_port = 3000 - processes = ["app"] - - [[services.ports]] - port = 80 - handlers = ["http"] - force_https = true - - [[services.ports]] - port = 443 - handlers = ["tls", "http"] - [services.concurrency] - type = "connections" - hard_limit = 25 - soft_limit = 20 - - [[services.tcp_checks]] - interval = "15s" - timeout = "2s" - grace_period = "1s"