The screen won't open (the deploy itself seems to be working).

Thanks for your time.
Question please.
What we would like to achieve
Deployment was successful but for some reason the screen does not open. We would like to determine the cause, fix it, and be able to open it. (It is a simple app with simple devise only login, sign up, etc.)

Current Status
Send logs. Also, we are doing it in a way that uses credentials.yml.enc and master.key.

Development environment
ruby ‘3.2.2’
‘rails’, ‘~> 6.1.7’, ‘>= 6.1.7.6’
M1Mac

What we have tried
I read the documentation and searched past questions but couldn’t figure it out.

Please give me any hints you can give me.
I would appreciate any help you can give me.

$ fly logs -a article-app1

Waiting for logs...

2023-11-08T13:19:35.036 app[32874ddec59ee8] nrt [info] INFO Umounting /dev/vdb from /data

2023-11-08T13:19:35.038 app[32874ddec59ee8] nrt [info] WARN hallpass exited, pid: 314, status: signal: 15 (SIGTERM)

2023-11-08T13:19:35.042 app[32874ddec59ee8] nrt [info] 2023/11/08 13:19:35 listening on [fdaa:1:1294:a7b:17d:b205:b4ad:2]:22 (DNS: [fdaa::3]:53)

2023-11-08T13:19:36.039 app[32874ddec59ee8] nrt [info] [ 4.355085] reboot: Restarting system

2023-11-08T13:19:36.273 runner[32874ddec59ee8] nrt [info] machine did not have a restart policy, defaulting to restart

2023-11-08T13:19:36.756 app[32874ddec59ee8] nrt [info] [ 0.044107] PCI: Fatal: No config space access function found

2023-11-08T13:19:37.003 app[32874ddec59ee8] nrt [info] INFO Starting init (commit: 15238e9)...

2023-11-08T13:19:37.033 app[32874ddec59ee8] nrt [info] INFO Mounting /dev/vdb at /data w/ uid: 1000, gid: 1000 and chmod 0755

2023-11-08T13:19:37.035 app[32874ddec59ee8] nrt [info] INFO Resized /data to 1056964608 bytes

2023-11-08T13:19:37.036 app[32874ddec59ee8] nrt [info] INFO starting statics vsock server

2023-11-08T13:19:37.037 app[32874ddec59ee8] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint ./bin/rails server` as rails

2023-11-08T13:19:37.046 app[32874ddec59ee8] nrt [info] INFO [fly api proxy] listening at /.fly/api

2023-11-08T13:19:37.054 app[32874ddec59ee8] nrt [info] 2023/11/08 13:19:37 listening on [fdaa:1:1294:a7b:17d:b205:b4ad:2]:22 (DNS: [fdaa::3]:53)

2023-11-08T13:19:39.677 app[32874ddec59ee8] nrt [info] => Booting Puma

2023-11-08T13:19:39.677 app[32874ddec59ee8] nrt [info] => Rails 6.1.7.6 application starting in production

2023-11-08T13:19:39.677 app[32874ddec59ee8] nrt [info] => Run `bin/rails server --help` for more startup options

2023-11-08T13:19:39.677 app[32874ddec59ee8] nrt [info] A server is already running. Check /rails/tmp/pids/server.pid.

2023-11-08T13:19:39.677 app[32874ddec59ee8] nrt [info] Exiting

2023-11-08T13:19:40.050 app[32874ddec59ee8] nrt [info] INFO Main child exited normally with code: 1

2023-11-08T13:19:40.051 app[32874ddec59ee8] nrt [info] INFO Starting clean up.

2023-11-08T13:19:40.051 app[32874ddec59ee8] nrt [info] INFO Umounting /dev/vdb from /data

2023-11-08T13:19:40.053 app[32874ddec59ee8] nrt [info] WARN hallpass exited, pid: 314, status: signal: 15 (SIGTERM)

2023-11-08T13:19:40.057 app[32874ddec59ee8] nrt [info] 2023/11/08 13:19:40 listening on [fdaa:1:1294:a7b:17d:b205:b4ad:2]:22 (DNS: [fdaa::3]:53)

2023-11-08T13:19:41.053 app[32874ddec59ee8] nrt [info] [ 4.341622] reboot: Restarting system

2023-11-08T13:19:41.312 runner[32874ddec59ee8] nrt [info] machine did not have a restart policy, defaulting to restart

2023-11-08T13:19:41.728 app[32874ddec59ee8] nrt [info] [ 0.045215] PCI: Fatal: No config space access function found

2023-11-08T13:19:41.987 app[32874ddec59ee8] nrt [info] INFO Starting init (commit: 15238e9)...

2023-11-08T13:19:42.016 app[32874ddec59ee8] nrt [info] INFO Mounting /dev/vdb at /data w/ uid: 1000, gid: 1000 and chmod 0755

2023-11-08T13:19:42.018 app[32874ddec59ee8] nrt [info] INFO Resized /data to 1056964608 bytes

2023-11-08T13:19:42.018 app[32874ddec59ee8] nrt [info] INFO starting statics vsock server

2023-11-08T13:19:42.019 app[32874ddec59ee8] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint ./bin/rails server` as rails

2023-11-08T13:19:42.031 app[32874ddec59ee8] nrt [info] INFO [fly api proxy] listening at /.fly/api

2023-11-08T13:19:42.041 app[32874ddec59ee8] nrt [info] 2023/11/08 13:19:42 listening on [fdaa:1:1294:a7b:17d:b205:b4ad:2]:22 (DNS: [fdaa::3]:53)

2023-11-08T13:19:44.874 app[32874ddec59ee8] nrt [info] => Booting Puma

2023-11-08T13:19:44.874 app[32874ddec59ee8] nrt [info] => Rails 6.1.7.6 application starting in production

2023-11-08T13:19:44.874 app[32874ddec59ee8] nrt [info] => Run `bin/rails server --help` for more startup options

2023-11-08T13:19:44.875 app[32874ddec59ee8] nrt [info] A server is already running. Check /rails/tmp/pids/server.pid.

2023-11-08T13:19:44.875 app[32874ddec59ee8] nrt [info] Exiting

2023-11-08T13:19:45.032 app[32874ddec59ee8] nrt [info] INFO Main child exited normally with code: 1

2023-11-08T13:19:45.033 app[32874ddec59ee8] nrt [info] INFO Starting clean up.

2023-11-08T13:19:45.033 app[32874ddec59ee8] nrt [info] INFO Umounting /dev/vdb from /data

2023-11-08T13:19:45.034 app[32874ddec59ee8] nrt [info] WARN hallpass exited, pid: 314, status: signal: 15 (SIGTERM)

2023-11-08T13:19:45.039 app[32874ddec59ee8] nrt [info] 2023/11/08 13:19:45 listening on [fdaa:1:1294:a7b:17d:b205:b4ad:2]:22 (DNS: [fdaa::3]:53)

2023-11-08T13:19:46.036 app[32874ddec59ee8] nrt [info] [ 4.350835] reboot: Restarting system

2023-11-08T13:19:46.281 runner[32874ddec59ee8] nrt [info] machine did not have a restart policy, defaulting to restart

2023-11-08T13:19:47.825 app[32874ddec59ee8] nrt [info] [ 0.047702] PCI: Fatal: No config space access function found

2023-11-08T13:19:48.097 app[32874ddec59ee8] nrt [info] INFO Starting init (commit: 15238e9)...

2023-11-08T13:19:48.126 app[32874ddec59ee8] nrt [info] INFO Mounting /dev/vdb at /data w/ uid: 1000, gid: 1000 and chmod 0755

2023-11-08T13:19:48.128 app[32874ddec59ee8] nrt [info] INFO Resized /data to 1056964608 bytes

2023-11-08T13:19:48.129 app[32874ddec59ee8] nrt [info] INFO starting statics vsock server

2023-11-08T13:19:48.129 app[32874ddec59ee8] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint ./bin/rails server` as rails

2023-11-08T13:19:48.142 app[32874ddec59ee8] nrt [info] INFO [fly api proxy] listening at /.fly/api

2023-11-08T13:19:48.149 app[32874ddec59ee8] nrt [info] 2023/11/08 13:19:48 listening on [fdaa:1:1294:a7b:17d:b205:b4ad:2]:22 (DNS: [fdaa::3]:53)

2023-11-08T13:19:51.045 app[32874ddec59ee8] nrt [info] => Booting Puma

2023-11-08T13:19:51.045 app[32874ddec59ee8] nrt [info] => Rails 6.1.7.6 application starting in production

2023-11-08T13:19:51.045 app[32874ddec59ee8] nrt [info] => Run `bin/rails server --help` for more startup options

2023-11-08T13:19:51.626 app[32874ddec59ee8] nrt [info] Puma starting in single mode...

2023-11-08T13:19:51.626 app[32874ddec59ee8] nrt [info] * Puma version: 5.6.7 (ruby 3.2.2-p53) ("Birdie's Version")

2023-11-08T13:19:51.626 app[32874ddec59ee8] nrt [info] * Min threads: 5

2023-11-08T13:19:51.626 app[32874ddec59ee8] nrt [info] * Max threads: 5

2023-11-08T13:19:51.626 app[32874ddec59ee8] nrt [info] * Environment: production

2023-11-08T13:19:51.626 app[32874ddec59ee8] nrt [info] * PID: 313

2023-11-08T13:19:51.627 app[32874ddec59ee8] nrt [info] * Listening on http://0.0.0.0:3000

2023-11-08T13:19:51.636 app[32874ddec59ee8] nrt [info] Use Ctrl-C to stop

2023-11-08T13:20:22.290 app[32874ddec59ee8] nrt [info] I, [2023-11-08T13:20:22.289932 #313] INFO -- : [7f275012-ebba-4707-a524-cf74ec1595f3] Started GET "/" for 2a09:8280:1::15:9ec2 at 2023-11-08 13:20:22 +0000

2023-11-08T13:20:22.291 app[32874ddec59ee8] nrt [info] I, [2023-11-08T13:20:22.291493 #313] INFO -- : [7f275012-ebba-4707-a524-cf74ec1595f3] Processing by Users::SessionsController#new as HTML

2023-11-08T13:20:22.371 app[32874ddec59ee8] nrt [info] I, [2023-11-08T13:20:22.371738 #313] INFO -- : [7f275012-ebba-4707-a524-cf74ec1595f3] Rendered devise/sessions/new.html.erb within layouts/application (Duration: 6.3ms | Allocations: 3818)

2023-11-08T13:20:30.911 app[32874ddec59ee8] nrt [info] [ 43.131562] Out of memory: Killed process 313 (ruby) total-vm:770528kB, anon-rss:128568kB, file-rss:0kB, shmem-rss:0kB, UID:1000 pgtables:556kB oom_score_adj:0

2023-11-08T13:20:30.925 proxy[32874ddec59ee8] nrt [error] could not complete HTTP request to instance: connection closed before message completed

2023-11-08T13:20:31.191 app[32874ddec59ee8] nrt [info] INFO Main child exited with signal (with signal 'SIGKILL', core dumped? false)

2023-11-08T13:20:31.192 app[32874ddec59ee8] nrt [info] INFO Starting clean up.

2023-11-08T13:20:31.192 app[32874ddec59ee8] nrt [info] INFO Umounting /dev/vdb from /data

2023-11-08T13:20:31.194 app[32874ddec59ee8] nrt [info] WARN hallpass exited, pid: 314, status: signal: 15 (SIGTERM)

2023-11-08T13:20:31.196 app[32874ddec59ee8] nrt [info] INFO Process appears to have been OOM killed!

2023-11-08T13:20:31.203 app[32874ddec59ee8] nrt [info] 2023/11/08 13:20:31 listening on [fdaa:1:1294:a7b:17d:b205:b4ad:2]:22 (DNS: [fdaa::3]:53)

2023-11-08T13:20:32.194 app[32874ddec59ee8] nrt [info] [ 44.414993] reboot: Restarting system

2023-11-08T13:20:32.374 app[32874ddec59ee8] nrt [info] Out of memory: Killed process

2023-11-08T13:20:32.456 runner[32874ddec59ee8] nrt [info] machine did not have a restart policy, defaulting to restart

2023-11-08T13:20:34.500 app[32874ddec59ee8] nrt [info] [ 0.043779] PCI: Fatal: No config space access function found

2023-11-08T13:20:34.747 app[32874ddec59ee8] nrt [info] INFO Starting init (commit: 15238e9)...

2023-11-08T13:20:34.775 app[32874ddec59ee8] nrt [info] INFO Mounting /dev/vdb at /data w/ uid: 1000, gid: 1000 and chmod 0755

2023-11-08T13:20:34.778 app[32874ddec59ee8] nrt [info] INFO Resized /data to 1056964608 bytes

2023-11-08T13:20:34.778 app[32874ddec59ee8] nrt [info] INFO starting statics vsock server

2023-11-08T13:20:34.779 app[32874ddec59ee8] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint ./bin/rails server` as rails

2023-11-08T13:20:34.788 app[32874ddec59ee8] nrt [info] INFO [fly api proxy] listening at /.fly/api

2023-11-08T13:20:34.796 app[32874ddec59ee8] nrt [info] 2023/11/08 13:20:34 listening on [fdaa:1:1294:a7b:17d:b205:b4ad:2]:22 (DNS: [fdaa::3]:53)

2023-11-08T13:20:37.823 app[32874ddec59ee8] nrt [info] => Booting Puma

2023-11-08T13:20:37.823 app[32874ddec59ee8] nrt [info] => Rails 6.1.7.6 application starting in production

2023-11-08T13:20:37.823 app[32874ddec59ee8] nrt [info] => Run `bin/rails server --help` for more startup options

2023-11-08T13:20:38.357 app[32874ddec59ee8] nrt [info] Puma starting in single mode...

2023-11-08T13:20:38.357 app[32874ddec59ee8] nrt [info] * Puma version: 5.6.7 (ruby 3.2.2-p53) ("Birdie's Version")

2023-11-08T13:20:38.357 app[32874ddec59ee8] nrt [info] * Min threads: 5

2023-11-08T13:20:38.357 app[32874ddec59ee8] nrt [info] * Max threads: 5

2023-11-08T13:20:38.357 app[32874ddec59ee8] nrt [info] * Environment: production

2023-11-08T13:20:38.357 app[32874ddec59ee8] nrt [info] * PID: 313

2023-11-08T13:20:38.357 app[32874ddec59ee8] nrt [info] * Listening on http://0.0.0.0:3000

2023-11-08T13:20:38.361 app[32874ddec59ee8] nrt [info] Use Ctrl-C to stop

2023-11-08T13:24:24.851 app[32874ddec59ee8] nrt [info] I, [2023-11-08T13:24:24.850909 #313] INFO -- : [b4f691c0-ee41-492d-9ad5-2e88a8ce3566] Started GET "/" for 2a09:8280:1::15:9ec2 at 2023-11-08 13:24:24 +0000

2023-11-08T13:24:24.853 app[32874ddec59ee8] nrt [info] I, [2023-11-08T13:24:24.852814 #313] INFO -- : [b4f691c0-ee41-492d-9ad5-2e88a8ce3566] Processing by Users::SessionsController#new as HTML

2023-11-08T13:24:24.923 app[32874ddec59ee8] nrt [info] I, [2023-11-08T13:24:24.923522 #313] INFO -- : [b4f691c0-ee41-492d-9ad5-2e88a8ce3566] Rendered devise/sessions/new.html.erb within layouts/application (Duration: 7.1ms | Allocations: 3816)

#Dockerfile
# syntax = docker/dockerfile:1

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

LABEL fly_launch_runtime="rails"

# 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_VERSION=14.21.3
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 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 .yarnrc package.json yarn.lock ./
COPY --link .yarn/releases/* .yarn/releases/
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 curl libsqlite3-0 postgresql-client && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives

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

# Run and own only the runtime files as a non-root user for security
RUN useradd rails --create-home --shell /bin/bash && \
    chown -R rails:rails db log storage tmp
USER 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"]


#fly.toml
# fly.toml app configuration file generated for article-app1 on 2023-11-08T15:33:30+09:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "article-app1"
primary_region = "nrt"
console_command = "/rails/bin/rails console"

[build]

[[mounts]]
  source = "data"
  destination = "/data"

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

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

HTTP ERROR 502!

スクリーンショット 2023-11-08 22.39.49|690x470

The problem is in your .dockerignore. It should have lines like the following:

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/.keep

Rails detects that there already is a server running by the presence of a file named tmp/pids/server.pid which it creates at server startup. At the time you deployed you had a server running on your local machine and that file was included in the build. The solution is to make sure that that file is excluded by your dockerignore file.

1 Like

Thank you. When I get home, I’ll add it to the docker ignore and try again as soon as I get home, I couldn’t have figured it out on my own. Thanks again for your valuable answers.