Skip to content

Commit

Permalink
Remove fly.io
Browse files Browse the repository at this point in the history
  • Loading branch information
duffn committed Jan 6, 2024
1 parent fe7a302 commit d702441
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 130 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/deploy-to-fly.yml

This file was deleted.

78 changes: 0 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 <my-app-name> <my-app-name>-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=<contents of above fly_jwtRS256.key>
GRAPE_BOILERPLATE_SETTINGS__JWT__PUBLIC_KEY=<contents of above fly_jwtRS256.key.pub>
```

- 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).
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
36 changes: 0 additions & 36 deletions fly.toml

This file was deleted.

0 comments on commit d702441

Please sign in to comment.