Hey guys, I am relatively new to building full stack apps, and this is really my first time deploying a proper full stack app. While trying to do so, I got the following error (stated in title of post) when I entered “fly deploy”, with the following message:
=> ERROR [build 6/6] RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile 2.4s
------
> [build 6/6] RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile:
2.323 Error retrieving instance profile credentials: Failed to open TCP connection to 169.254.169.254:80 (Network is unreachable - connect(2) for "169.254.169.254" port 80)
2.328 bin/rails aborted!
2.329 Aws::Errors::MissingRegionError: No region was provided. Configure the `:region` option or export the region name to ENV['AWS_REGION'] (Aws::Errors::MissingRegionError)
2.329
2.329 raise Errors::MissingRegionError if region.nil? || region == ''
2.329 ^^^^^^^^^^^^^^^^^^^^^^^^^^
2.329 /rails/app/models/user.rb:8:in `<class:User>'
2.329 /rails/app/models/user.rb:3:in `<main>'
2.329 /rails/config/routes.rb:2:in `block in <main>'
2.329 /rails/config/routes.rb:1:in `<main>'
2.329 /rails/config/environment.rb:5:in `<main>'
2.329 Tasks: TOP => environment
2.329 (See full trace by running task with --trace)
------
Error: failed to fetch an image or build from source: error building: failed to solve: process "/bin/sh -c SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile" did not complete successfully: exit code: 1
hunyao@macbookpro odinbook %
I am running two different things within my program which could be potential problems, though I’m not sure how to identify which might be causing them, and how to solve it:
- Using Omniauth for google. I have already implemented as per one of the article by doing this:
if Rails.application.credentials.google
config.omniauth :google_oauth2, Rails.application.credentials.dig(:google, :google_client_id), Rails.application.credentials.dig(:google, :google_client_secret), {}
end
Within “EDITOR=vi rails credentials:edit” is as follows:
google:
google_client_id: *********
google_client_secret: ************
- I am using ActiveStorage to store user profile pictures (stores from either google profile picture via API, or through uploading their own profile picture)
→ The potential problem here is that I am using local disk for storage currently, although fly.io has automatically generated tigris for me, which is also causing this error message regarding aws
2.329 Aws::Errors::MissingRegionError: No region was provided. Configure the `:region` option or export the region name to ENV['AWS_REGION'] (Aws::Errors::MissingRegionError)
2.329
2.329 raise Errors::MissingRegionError if region.nil? || region == ''
2.329 ^^^^^^^^^^^^^^^^^^^^^^^^^^
Here’s the code within my storage.yml:
test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
local:
service: Disk
root: <%= Rails.root.join("storage") %>
# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
# amazon:
# service: S3
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
# region: us-east-1
# bucket: your_own_bucket-<%= Rails.env %>
# Remember not to checkin your GCS keyfile to a repository
# google:
# service: GCS
# project: your_project
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
# bucket: your_own_bucket-<%= Rails.env %>
# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
# microsoft:
# service: AzureStorage
# storage_account_name: your_account_name
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
# container: your_container_name-<%= Rails.env %>
# mirror:
# service: Mirror
# primary: local
# mirrors: [ amazon, google, microsoft ]
tigris:
service: S3
access_key_id: <%= ENV["AWS_ACCESS_KEY_ID"] %>
secret_access_key: <%= ENV["AWS_SECRET_ACCESS_KEY"] %>
endpoint: <%= ENV["AWS_ENDPOINT_URL_S3"] %>
bucket: <%= ENV["BUCKET_NAME"] %>
I have also tried running bin/rails generate dockerfile --tigris
but to no avail:
conflict Dockerfile
Overwrite /Users/hunyao/repos/odinbook/Dockerfile? (enter "h" for help) [Ynaqdhm] y
force Dockerfile
conflict .dockerignore
Overwrite /Users/hunyao/repos/odinbook/.dockerignore? (enter "h" for help) [Ynaqdhm] y
force .dockerignore
conflict bin/docker-entrypoint
Overwrite /Users/hunyao/repos/odinbook/bin/docker-entrypoint? (enter "h" for help) [Ynaqdhm] y
force bin/docker-entrypoint
identical fly.toml
identical config/dockerfile.yml
unchanged config/storage.yml
unchanged config/environments/production.yml
Could someone please advise me on this? Thank you.