I want to understand the meaning of the error and solve the error

Error failed to fetch an image or build from source: error building: executor failed running [/bin/bash -o pipefail -c ${BUILD_COMMAND}]: exit code: 1

What I want to achieve = I want to deploy
Current status = I get a separate error
What I tried = I looked at the documentation, but I can’t find a case similar to mine.
What I felt = code1 and an error message appear, but please tell me what this means and how to eliminate the error.

hello! everyone!
I’m trying to deploy somehow on fly.io.
I am facing a problem that my wits cannot solve.
Please lend me your wisdom.

If you’re not on M1 Mac and friends, then see if flyctl deploy --local-only --verbose <other-args> works or reveals any problems in the Dockerfile you’re trying to build?

If you’re not building and deploying using (hand-written) Dockerfiles, then can you share the framework / runtime / language is the app using?

1 Like

If you’re not on M1 Mac and friends, then see if flyctl deploy --local-only --verbose works or reveals any problems in the Dockerfile you’re trying to build?

→flyctl deploy --local-only --verbose
I tried typing the command As a result, I got an error.

If you’re not building and deploying using (hand-written) Dockerfiles, then can you share the framework / runtime / language is the app using?

→What does Dockerfiles, then can you share the framework / runtime / language is the app using?

What exactly should be fixed? Or what command should I use?

Error failed to fetch an image or build from source: docker is unavailable to build the deployment image

thank you.

Docker itself I’m a newbie not understanding much yet.

I’ll look into Docker when I get home from work. Thank you for your continued guidance. !

share the framework / runtime / language is the app using?

→I use rails.
→runtime is I do not understand.
→language is ruby.

OK, in that case, I can tell you what the line you quoted means:

Your Dockerfile likely have the following line:

ARG BUILD_COMMAND="bin/rails fly:build"

And you have a file named lib/tasks/fly.rake, which contains a line like the following:

task :build => 'assets:precompile'

So this means that the failure occurred during an attempt to precompile your assets.

The sequence generally is: something fails, that failure produces a stack traceback, and then the program exits with a non-zero status code. Now we know which program exited. Setting the messages that preceeded the one you shared with us would be helpful in knowing why that program exited.

2 Likes

Rubys, ignoramous, thank you very much for yesterday.
After that, I investigated and tried as follows, but the following error appears.
Do you have any solutions?
if you’d kindly teach me.

=> [gems 1/2] COPY Gemfile* ./ 0.1s
=> [gems 2/2] RUN bundle install && rm -rf vendor/bundle/ruby//cache 169.8s
=> [stage-3 2/7] COPY --from=gems /app /app 0.8s
=> [stage-3 3/7] COPY --from=gems /usr/lib/fullstaq-ruby/versions /usr/lib/fullstaq-ruby/versions 0.4s
=> [stage-3 4/7] COPY --from=gems /usr/local/bundle /usr/local/bundle 0.2s
=> [stage-3 5/7] COPY . . 0.7s
=> [stage-3 6/7] RUN chmod +x /app/bin/
&& sed -i ‘s/ruby.exe\r*/ruby/’ /app/bin/* && sed -i ‘s/ruby\r*/ruby/’ 0.3s
=> ERROR [stage-3 7/7] RUN bin/rails fly:build 1.4s

[stage-3 7/7] RUN bin/rails fly:build:
#19 1.410 rails aborted!
#19 1.410 ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See GitHub - rails/execjs: Run JavaScript code from Ruby for a list of available runtimes.
#19 1.410 /app/vendor/bundle/ruby/2.7.0/gems/execjs-2.8.1/lib/execjs/runtimes.rb:58:in autodetect' #19 1.410 /app/vendor/bundle/ruby/2.7.0/gems/execjs-2.8.1/lib/execjs.rb:5:in module:ExecJS
#19 1.410 /app/vendor/bundle/ruby/2.7.0/gems/execjs-2.8.1/lib/execjs.rb:4:in <top (required)>' #19 1.410 /app/vendor/bundle/ruby/2.7.0/gems/uglifier-4.2.0/lib/uglifier.rb:5:in require’
#19 1.410 /app/vendor/bundle/ruby/2.7.0/gems/uglifier-4.2.0/lib/uglifier.rb:5:in <top (required)>' #19 1.410 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in require’
#19 1.410 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in block (2 levels) in require' #19 1.410 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in each’
#19 1.410 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in block in require' #19 1.410 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in each’
#19 1.410 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in require' #19 1.410 /usr/local/bundle/gems/bundler-2.1.4/lib/bundler.rb:174:in require’
#19 1.410 /app/config/application.rb:6:in <top (required)>' #19 1.410 /app/Rakefile:4:in require_relative’
#19 1.410 /app/Rakefile:4:in <top (required)>' #19 1.410 /app/vendor/bundle/ruby/2.7.0/gems/railties-5.1.7/lib/rails/commands/rake/rake_command.rb:20:in block in perform’
#19 1.410 /app/vendor/bundle/ruby/2.7.0/gems/railties-5.1.7/lib/rails/commands/rake/rake_command.rb:18:in perform' #19 1.410 /app/vendor/bundle/ruby/2.7.0/gems/railties-5.1.7/lib/rails/command.rb:46:in invoke’
#19 1.410 /app/vendor/bundle/ruby/2.7.0/gems/railties-5.1.7/lib/rails/commands.rb:16:in <top (required)>' #19 1.410 bin/rails:10:in require’
#19 1.410 bin/rails:10:in `’
#19 1.410 (See full trace by running task with --trace)


Error failed to fetch an image or build from source: error building: executor failed running [/bin/bash -o pipefail -c ${BUILD_COMMAND}]: exit code: 1

↓dockerfile

syntax = docker/dockerfile:experimental

Dockerfile used to build a deployable image for a Rails application.

Adjust as required.

Common adjustments you may need to make over time:

* Modify version numbers for Ruby, Bundler, and other products.

* Add library packages needed at build time for your gems, node modules.

* Add deployment packages needed by your application

* Add (often fake) secrets needed to compile your assets

#######################################################################

Learn more about the chosen Ruby stack, Fullstaq Ruby, here:

GitHub - evilmartians/fullstaq-ruby-docker: Docker image for Ruby build from Fullstaq packages based on Debian 9, Debian 10, and Debian 11..

We recommend using the highest patch level for better security and

performance.

ARG RUBY_VERSION=2.7.7
ARG VARIANT=jemalloc-slim
FROM Quay as base

LABEL fly_launch_runtime=“rails”

ARG BUNDLER_VERSION=2.1.4

ARG RAILS_ENV=production
ENV RAILS_ENV=${RAILS_ENV}

ENV RAILS_SERVE_STATIC_FILES true
ENV RAILS_LOG_TO_STDOUT true

ARG BUNDLE_WITHOUT=development:test
ARG BUNDLE_PATH=vendor/bundle
ENV BUNDLE_PATH ${BUNDLE_PATH}
ENV BUNDLE_WITHOUT ${BUNDLE_WITHOUT}

RUN mkdir /app
WORKDIR /app
RUN mkdir -p tmp/pids

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

#######################################################################

install packages only needed at build time

FROM base as build_deps

ARG BUILD_PACKAGES=“git build-essential libpq-dev wget vim curl gzip xz-utils libsqlite3-dev”
ENV BUILD_PACKAGES ${BUILD_PACKAGES}

RUN --mount=type=cache,id=dev-apt-cache,sharing=locked,target=/var/cache/apt
–mount=type=cache,id=dev-apt-lib,sharing=locked,target=/var/lib/apt
apt-get update -qq &&
apt-get install --no-install-recommends -y ${BUILD_PACKAGES}
&& rm -rf /var/lib/apt/lists /var/cache/apt/archives

#######################################################################

install gems

FROM build_deps as gems

COPY Gemfile* ./
RUN bundle install && rm -rf vendor/bundle/ruby/*/cache

#######################################################################

install deployment packages

FROM base

ARG DEPLOY_PACKAGES=“postgresql-client file vim curl gzip libsqlite3-0”
ENV DEPLOY_PACKAGES=${DEPLOY_PACKAGES}

RUN --mount=type=cache,id=prod-apt-cache,sharing=locked,target=/var/cache/apt
–mount=type=cache,id=prod-apt-lib,sharing=locked,target=/var/lib/apt
apt-get update -qq &&
apt-get install --no-install-recommends -y
${DEPLOY_PACKAGES}
&& rm -rf /var/lib/apt/lists /var/cache/apt/archives

copy installed gems

COPY --from=gems /app /app
COPY --from=gems /usr/lib/fullstaq-ruby/versions /usr/lib/fullstaq-ruby/versions
COPY --from=gems /usr/local/bundle /usr/local/bundle

#######################################################################

Deploy your application

COPY . .

Adjust binstubs to run on Linux and set current working directory

RUN chmod +x /app/bin/* &&
sed -i ‘s/ruby.exe\r*/ruby/’ /app/bin/* &&
sed -i ‘s/ruby\r*/ruby/’ /app/bin/* &&
sed -i ‘/^#!/aDir.chdir File.expand_path(“…”, dir)’ /app/bin/*

The following enable assets to precompile on the build server. Adjust

as necessary. If no combination works for you, see:

Existing Rails Apps · Fly Docs

ENV SECRET_KEY_BASE 1

ENV AWS_ACCESS_KEY_ID=1

ENV AWS_SECRET_ACCESS_KEY=1

Run build task defined in lib/tasks/fly.rake

ARG BUILD_COMMAND=“bin/rails fly:build”
RUN ${BUILD_COMMAND}

Default server start instructions. Generally Overridden by fly.toml.

ENV PORT 8080
ARG SERVER_COMMAND=“bin/rails fly:server”
ENV SERVER_COMMAND ${SERVER_COMMAND}
CMD ${SERVER_COMMAND}

My hypothesis is that

running [/bin/bash -o pipefail -c ${BUILD_COMMAND}]: exit code: 1

I understand that -o pipefail is a bash script that prevents further processing from running.

As pointed out by Rubys

Run build task defined in lib/tasks/fly.rake

ARG BUILD_COMMAND=“bin/rails fly:build”
RUN ${BUILD_COMMAND}

and was in my dockerfile.

The process runs so much that I think I can deploy it a little more, and an error appears at the end.

I would like to improve it somehow.
Could you please lend me your help?

↓fly.toml

fly.toml file generated for sedora-republic on 2022-12-28T02:21:54+09:00

app = “sedora-republic”
kill_signal = “SIGINT”
kill_timeout = 5
processes =

[build]
[build.args]
BUILD_COMMAND = “bin/rails fly:build”
SERVER_COMMAND = “bin/rails fly:server”

[deploy]
release_command = “bin/rails fly:release”

[env]
PORT = “8080”

[experimental]
allowed_public_ports =
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 = “/app/public”
url_prefix = “/”

Add nodejs to the DEPLOY_PACKAGES line in your Dockerfile:

ARG DEPLOY_PACKAGES=“postgresql-client file vim curl gzip libsqlite3-0 nodejs”
1 Like

thank you so much.
I’ll give it a try. Where should I put it in my dockerfile? Are you the first one?

I found it on line 75.
I will rewrite it.

I got errer

→ docker host: 20.10.12 linux x86_64
[+] Building 1.8s (0/1)
[+] Building 6.7s (14/20)
=> [internal] load remote build context 0.0s
=> copy /context / 1.3s
=> resolve image config for docker.io/docker/dockerfile:experimental 1.6s
=> CACHED docker-image://docker.io/docker/dockerfile:experimental@sha256:600e5c62eedff338b3f7a0850beb7c05866e0ef27b2d2e 0.0s
=> [internal] load metadata for Quay 0.8s
=> [base 1/5] FROM Quay 0.0s
=> CACHED [base 2/5] RUN mkdir /app 0.0s
=> CACHED [base 3/5] WORKDIR /app 0.0s
=> CACHED [base 4/5] RUN mkdir -p tmp/pids 0.0s
=> CACHED [base 5/5] RUN gem update --system --no-document && gem install -N bundler -v 2.1.4 0.0s
=> ERROR [stage-3 1/7] RUN --mount=type=cache,id=prod-apt-cache,sharing=locked,target=/var/cache/apt --mount=type=c 2.5s
=> CACHED [build_deps 1/1] RUN --mount=type=cache,id=dev-apt-cache,sharing=locked,target=/var/cache/apt --mount=typ 0.0s
=> CACHED [gems 1/2] COPY Gemfile* ./ 0.0s
=> CANCELED [gems 2/2] RUN bundle install && rm -rf vendor/bundle/ruby/*/cache 2.5s

[stage-3 1/7] RUN --mount=type=cache,id=prod-apt-cache,sharing=locked,target=/var/cache/apt --mount=type=cache,id=prod-apt-lib,sharing=locked,target=/var/lib/apt apt-get update -qq && apt-get install --no-install-recommends -y “postgresql-client && rm -rf /var/lib/apt/lists /var/cache/apt/archives:
#11 1.462 Reading package lists…
#11 2.188 Building dependency tree…
#11 2.377 Reading state information…
#11 2.489 E: Unable to locate package “postgresql-client


Error failed to fetch an image or build from source: error building: executor failed running [/bin/bash -o pipefail -c apt-get update -qq && apt-get install --no-install-recommends -y ${DEPLOY_PACKAGES} && rm -rf /var/lib/apt/lists /var/cache/apt/archives]: exit code: 100

Sorry. Apparently this forum software replaces quotation marks (Unicode Character 'QUOTATION MARK' (U+0022)) with left and right double quotation marks (Unicode Character 'LEFT DOUBLE QUOTATION MARK' (U+201C) and Unicode Character 'RIGHT DOUBLE QUOTATION MARK' (U+201D)). Please replace the quotation marks in that line and try again.

1 Like

ARG DEPLOY_PACKAGES=“postgresql-client file vim curl gzip libsqlite3-0 nodejs”


ARG DEPLOY_PACKAGES=‘postgresql-client file vim curl gzip libsqlite3-0 nodejs’

please tell me

is that’s ok?

No, it needs to be double quotes, not single quotes. But not the curly left and right double quotes that you get when you copy and paste from this forum, but the straight up and down ones that you find on your keyboard.

1 Like

Thanks a lot !
Finally I deproyed but I got this

An unhandled lowlevel error occurred. The application logs may have details.

1 Like

Try running flyclt logs to see the server console. The error should show up there.

1 Like