Fly.io deploy

Hi I wanna solve a problem.

-What I want to achieve
Deploy my app with Fly.io.

-current situation
flyctl auth login →
gem install fly.io-railsupgrade.→
Sending build context to Docker daemon after 39.85kB
I get an error like the one below.

Error failed to fetch an image or build from source: error building: Error response from daemon: invalid reference format

-environment
・windows 11 (ver 22H2)
・Rails 5.1.6
・Ruby 2.7.7

I have no fly.rake file

fly.toml file generated for -a on 2023-02-05T18:35:45+09:00

app = “-a”
kill_signal = “SIGINT”
kill_timeout = 5
processes =

[env]

[experimental]
auto_rollback = true

[[services]]
http_checks =
internal_port = 8080
processes = [“app”]
protocol = “tcp”
script_checks =
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = “connections”

[[services.ports]]
force_https = true
handlers = [“http”]
port = 80

[[services.ports]]
handlers = [“tls”, “http”]
port = 443

[[services.tcp_checks]]
grace_period = “1s”
interval = “15s”
restart_limit = 0
timeout = “2s”

[[statics]]
guest_path = “/rails/public”
url_prefix = “/”

syntax = docker/dockerfile:1

Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile

ARG RUBY_VERSION=2.7.7
FROM ruby:$RUBY_VERSION-slim as base

Rails app lives here

WORKDIR /rails

Set production environment

ENV RAILS_ENV=“production”
BUNDLE_PATH=“vendor/bundle”
BUNDLE_WITHOUT=“development:test”

Update gems and preinstall the desired version of bundler

ARG BUNDLER_VERSION=2.4.5
RUN gem update --system --no-document &&
gem install -N bundler -v ${BUNDLER_VERSION}

Install packages needed to install nodejs

RUN apt-get update -qq &&
apt-get install --no-install-recommends -y curl unzip &&
rm -rf /var/lib/apt/lists /var/cache/apt/archives

Install Node.js

ARG NODE_VERSION=18.13.0
RUN curl -fsSL https://fnm.vercel.app/install | bash &&
/root/.local/share/fnm/fnm install $NODE_VERSION
ENV PATH=/root/.local/share/fnm/aliases/default/bin/:$PATH

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 redis

Install application gems

COPY Gemfile Gemfile.lock ./
RUN bundle ${BUNDLER_VERSION} install

Install node modules

COPY package.json .
RUN npm install

Copy application code

COPY . .

Adjust binfiles to be executable on Linux

RUN chmod +x bin/*

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 postgresql-client redis &&
rm -rf /var/lib/apt/lists /var/cache/apt/archives

Copy built application from previous stage

COPY --from=build /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”]

It looks like somehow you managed to name your app -a, and docker isn’t happy with names that start with a dash.

The easiest way to delete that app may be from the dashboard. Type flyctl dashboard to bring up the web page, click on settings and then delete the app from there.

Next delete fly.toml.

At that point you should be able to run fly launch again.

2 Likes

I appreciate your help rubys! I could delete my app then I try to deploy.

Now I’m having another error like the one below

→ v0 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v1

→ Troubleshooting guide at Troubleshooting your Deployment · Fly Docs
Error abort

-current situation
gem install fly.io-rails →
flyctl launch --name attendancea --region nrt→
flyctl volumes create attendancea --region nrt→
flyctl secrets set DATABASE_URL=sqlite3:///mnt/name/production.sqlite→
flyctl deploy

I try several times but this step did not create a fly.rake file. So when I tried to deploy, I got the above error.

-my fly.toml file

fly.toml file generated for attendancea on 2023-02-13T22:02:09+09:00

app = “attendancea”
kill_signal = “SIGINT”
kill_timeout = 5
processes =

[env]

[experimental]
auto_rollback = true

[[services]]
http_checks =
internal_port = 3000
processes = [“app”]
protocol = “tcp”
script_checks =
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = “connections”

[[services.ports]]
force_https = true
handlers = [“http”]
port = 80

[[services.ports]]
handlers = [“tls”, “http”]
port = 443

[[services.tcp_checks]]
grace_period = “1s”
interval = “15s”
restart_limit = 0
timeout = “2s”

[[statics]]
guest_path = “/rails/public”
url_prefix = “/”

fly.io-rails is experimental. Apparently it is not working for you. So let’s try without it. Remove it from your Gemfile, delete your app, Dockerfile, and fly.toml then run:

fly launch
fly deploy

Note: If you are running flyctl version v0.0.451 or later there will be no fly.rake file generated. If you are running an earlier version of flyctl, please upgrade before running the above commands.

1 Like

Thank you so much for your help! Much appreciated. I have completed deploy!