Rails deploy successful but not app is not responding to requests

Hello, I am migrating a Rails 6.1 app from Heroku and have managed all of the steps and deployed successfully. However, once deployed, puma is not responding or showing any requests received in fly logs.

e.g.

# fly.toml
app = "my-app"
primary_region = "sea"

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true

[[statics]]
  guest_path = "/rails/public"
  url_prefix = "/"
# bin/rails generated dockerfile
# syntax = docker/dockerfile:1

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=2.7.6
FROM ruby:$RUBY_VERSION-slim as base

# Rails app lives here
WORKDIR /rails

# Set production environment
ENV RAILS_ENV="production" \
    BUNDLE_WITHOUT="development:test" \
    BUNDLE_DEPLOYMENT="1"

# Update gems and bundler
RUN gem update --system --no-document && \
    gem install -N bundler

# Install packages needed to install nodejs
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y curl && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Install Node.js
ARG NODE_ENV=production
ARG NODE_VERSION=15.14.0
ENV PATH=/usr/local/node/bin:$PATH
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
    /tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
    rm -rf /tmp/node-build-master


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build gems and node modules
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential libpq-dev libvips node-gyp pkg-config python-is-python3

# Install yarn
ARG YARN_VERSION=1.22.19
RUN npm install -g yarn@$YARN_VERSION

# Build options
ENV PATH="/usr/local/node/bin:$PATH"

# Install application gems
COPY --link Gemfile Gemfile.lock ./
RUN bundle install && \
    bundle exec bootsnap precompile --gemfile && \
    rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git

# Install node modules
COPY --link package.json yarn.lock ./
RUN yarn install --frozen-lockfile

# Copy application code
COPY --link . .

# Precompile bootsnap code for faster boot times
RUN bundle exec bootsnap precompile app/ lib/

# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile


# Final stage for app image
FROM base

# Install packages needed for deployment
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y imagemagick libvips postgresql-client && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Run and own the application files as a non-root user for security
RUN useradd rails --home /rails --shell /bin/bash
USER rails:rails

# Copy built artifacts: gems, application
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build --chown=rails:rails /rails /rails

# Deployment options
ENV RAILS_LOG_TO_STDOUT="1" \
    RAILS_SERVE_STATIC_FILES="true"

# Entrypoint prepares the database.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD ["./bin/rails", "server"]

I have no idea why it’s not responding at all, I’ve tried using different ports. Hitting the myapp.fly.dev results in nothing.

Logs show that the deploy was successful and it’s ready:

2023-04-29T09:39:16.994 app[2d5fdaa2] sea [info] Starting init (commit: 15c0f38)...
2023-04-29T09:39:17.019 app[2d5fdaa2] sea [info] Preparing to run: `/rails/bin/docker-entrypoint ./bin/rails server` as rails
2023-04-29T09:39:17.039 app[2d5fdaa2] sea [info] 2023/04/29 09:39:17 listening on [fdaa:1:2334:a7b:105:2d5f:daa2:2]:22 (DNS: [fdaa::3]:53)
2023-04-29T09:39:20.077 app[2d5fdaa2] sea [info] D, [2023-04-29T09:39:20.077001 #526] DEBUG -- : (0.9ms) SELECT pg_try_advisory_lock(8540146439205381105)
2023-04-29T09:39:20.086 app[2d5fdaa2] sea [info] D, [2023-04-29T09:39:20.086293 #526] DEBUG -- : (1.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2023-04-29T09:39:20.094 app[2d5fdaa2] sea [info] D, [2023-04-29T09:39:20.094117 #526] DEBUG -- : ActiveRecord::InternalMetadata Load (0.8ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
2023-04-29T09:39:20.100 app[2d5fdaa2] sea [info] D, [2023-04-29T09:39:20.100148 #526] DEBUG -- : (1.0ms) SELECT pg_advisory_unlock(8540146439205381105)
2023-04-29T09:39:21.388 app[2d5fdaa2] sea [info] => Booting Puma
2023-04-29T09:39:21.388 app[2d5fdaa2] sea [info] => Rails 6.1.7.3 application starting in production
2023-04-29T09:39:21.388 app[2d5fdaa2] sea [info] => Run `bin/rails server --help` for more startup options
2023-04-29T09:39:22.292 app[2d5fdaa2] sea [info] Puma starting in single mode...
2023-04-29T09:39:22.292 app[2d5fdaa2] sea [info] * Version 5.0.4 (ruby 2.7.6-p219), codename: Spoony Bard
2023-04-29T09:39:22.292 app[2d5fdaa2] sea [info] * Min threads: 5, max threads: 5
2023-04-29T09:39:22.292 app[2d5fdaa2] sea [info] * Environment: production
2023-04-29T09:39:22.293 app[2d5fdaa2] sea [info] * Listening on http://0.0.0.0:3000
2023-04-29T09:39:22.296 app[2d5fdaa2] sea [info] Use Ctrl-C to stop

Presumably you (understandably) edited these prior to posting, so what I’m about to say isn’t going to be helpful, but these don’t match.

I don’t recognize the first comment in the Dockerfile, and actually believe that the syntax directive needs to precede it, but since you have deployed that’s also not a problem.

I’m stumped.

Nevermind! It was because I was using a fly.toml config for v2 apps, but somehow had created a v1 app.

The docs are very confusing and it was a long amount of trial and error to stumble on this. Can I submit improvements to the docs anywhere?

Cool! At the bottom of each doc page you should see:

Screenshot 2023-04-29 at 7.59.52 AM

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.