Skip to content

Commit

Permalink
chore: deployment
Browse files Browse the repository at this point in the history
* trying to deploy to fly.io

TODO: figure out secrets/db config for production
  • Loading branch information
sean-garwood committed Nov 21, 2024
1 parent f589463 commit 3485f32
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/fly-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/

name: Fly Deploy
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy app
runs-on: ubuntu-latest
concurrency: deploy-group # optional: ensure only one action runs at a time
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ gem "devise", "~> 4.9"
gem "faker", "~> 3.5"

gem "letter_opener", "~> 1.10", :group => :development

Check failure on line 65 in Gemfile

View workflow job for this annotation

GitHub Actions / lint

Style/HashSyntax: Use the new Ruby 1.9 hash syntax.

gem "dockerfile-rails", ">= 1.6", :group => :development

Check failure on line 67 in Gemfile

View workflow job for this annotation

GitHub Actions / lint

Style/HashSyntax: Use the new Ruby 1.9 hash syntax.
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ GEM
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
dockerfile-rails (1.6.24)
rails (>= 3.0.0)
drb (2.2.1)
erubi (1.13.0)
faker (3.5.1)
Expand Down Expand Up @@ -352,6 +354,7 @@ DEPENDENCIES
capybara
debug
devise (~> 4.9)
dockerfile-rails (>= 1.6)
faker (~> 3.5)
guard (~> 2.19)
guard-minitest (~> 2.4, >= 2.4.6)
Expand Down
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,54 @@ started below this list:
Before you move on, we would love it if you could send us your feedback on the
Ruby on Rails course. Getting user (you) feedback is important so we can
continue to improve the curriculum and get an idea of your experience.

## Issues

After running `fly launch`:

```bash
Save your credentials in a secure place -- you won't be able to see them again!
Connect to postgres
Any app within the Sean Garwood organization can connect to this Postgres using the above connection string
Now that you've set up Postgres, here's what you need to understand: <https://fly.io/docs/postgres/getting-started/what-you-should-know/>
Checking for existing attachments
Registering attachment
Creating database
Creating user
Postgres cluster top-odinbook-db is now attached to top-odinbook
The following secret was added to top-odinbook:
DATABASE_URL=postgres://top_odinbook:<[email protected]>:5432/top_odinbook?sslmode=disable
Postgres cluster top-odinbook-db is now attached to top-odinbook
Fetching gem metadata from <https://rubygems.org/>.........
Resolving dependencies...
WARN: Unresolved or ambiguous specs during Gem::Specification.reset:
stringio (>= 0)
Available/installed versions of this gem:
- 3.1.2
- 3.1.1
WARN: Clearing out unresolved specs. Try 'gem cleanup <gem>'
Please report a bug if this causes problems.
Running: bin/rails generate dockerfile --label=fly_launch_runtime:rails --skip --postgresql --no-prepare
skip Dockerfile
skip .dockerignore
skip bin/docker-entrypoint
create config/dockerfile.yml
Wrote config file fly.toml
Validating /home/ssg/courses/top/rails/projects/top_odinbook/fly.toml
✓ Configuration is valid
Your Rails app is prepared for deployment.
WARNING: One or more of your config initializer files appears to access
environment variables or Rails credentials. These values generally are not
available during the Docker build process, so you may need to update your
initializers to bypass portions of your setup during the build process.
More information on what needs to be done can be found at:
<https://fly.io/docs/rails/getting-started/existing/#access-to-environment-variables-at-build-time>.
Once ready: run 'fly deploy' to deploy your Rails app.
```
Empty file.
8 changes: 8 additions & 0 deletions config/dockerfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# generated by dockerfile-rails

---
options:
label:
fly_launch_runtime: rails
postgresql: true
prepare: false
45 changes: 45 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# fly.toml app configuration file generated for top-odinbook on 2024-11-20T20:23:01-05:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'top-odinbook'
primary_region = 'ewr'
console_command = '/rails/bin/rails console'

[build]

[deploy]
release_command = './bin/rails db:prepare'

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[checks]
[checks.status]
port = 3000
type = 'http'
interval = '10s'
timeout = '2s'
grace_period = '5s'
method = 'GET'
path = '/up'
protocol = 'http'
tls_skip_verify = false

[checks.status.headers]
X-Forwarded-Proto = 'https'

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1

[[statics]]
guest_path = '/rails/public'
url_prefix = '/'

0 comments on commit 3485f32

Please sign in to comment.