I am trying to deploy my app on fly.io. My app is using Rails API backend and React frontend. And I am having issues building the docker image to deploy.
My docker file looks like this:
syntax = docker/dockerfile:1
Stage 1: Build React App
FROM node:slim AS react
WORKDIR /app/client
COPY client/package.json client/package-lock.json ./
RUN npm install
COPY client/ ./
RUN npm run build
Stage 2: Build Rails API
FROM ruby:3.2.2-slim AS build
Install necessary packages for PostgreSQL and building gems
RUN apt-get update && apt-get install --yes build-essential git libpq-dev \
&& apt-get clean && rm -rf /var/lib/apt/lists
RUN gem install bundler
Set working directory for the Rails API
WORKDIR /app/demo
COPY Gemfile Gemfile.lock ./
Install dependencies
RUN bundle install --jobs=4 --retry=3 --without development test
Copy the rest of your application files
COPY . /app/demo
Stage 3: Final Image
FROM ruby:3.2.2-slim
Copy the built Rails app and React build
COPY --from=build /app/demo /app/demo
COPY --from=react /app/client/dist /app/demo/public
WORKDIR /app/demo
ENV RAILS_ENV=production
ENV RAILS_SERVE_STATIC_FILES=true
EXPOSE 3000
CMD [“bin/rails”, “server”]
And when I run the container I get this error:
$ docker run -p 3000:3000 flyaway
/usr/local/lib/ruby/3.2.0/bundler/definition.rb:524:in materialize': Could not find rails-7.1.4, pg-1.5.7, puma-6.4.2, bootsnap-1.18.4, rack-cors-2.0.2, debug-1.9.2, faker-3.4.2, dotenv-rails-3.1.2, rails-controller-testing-1.0.5, amadeus-5.2.1, faraday-2.11.0, flight_radar-0.2.1, opencage-geocoder-3.2.0, stripe-13.0.2, devise-4.9.4, devise-api-0.2.0, dockerfile-rails-1.6.22, redis-5.3.0, actioncable-7.1.4, actionmailbox-7.1.4, actionmailer-7.1.4, actionpack-7.1.4, actiontext-7.1.4, actionview-7.1.4, activejob-7.1.4, activemodel-7.1.4, activerecord-7.1.4, activestorage-7.1.4, activesupport-7.1.4, railties-7.1.4, nio4r-2.7.3, msgpack-1.7.2, rack-3.1.7, irb-1.14.0, reline-0.5.9, i18n-1.14.5, dotenv-3.1.2, faraday-net_http-3.3.0, logger-1.6.1, httparty-0.21.0, bcrypt-3.1.20, orm_adapter-0.5.0, responders-3.1.1, warden-1.2.9, dry-configurable-1.2.0, dry-initializer-3.1.1, dry-monads-1.6.0, dry-types-1.7.2, redis-client-0.22.2, websocket-driver-0.7.6, zeitwerk-2.6.18, mail-2.8.1, net-imap-0.4.15, net-smtp-0.5.0, rails-dom-testing-2.2.0, nokogiri-1.16.7-x86_64-linux, racc-1.8.1, rack-session-2.0.0, rack-test-2.1.0, rails-html-sanitizer-1.6.0, globalid-1.2.1, builder-3.3.0, erubi-1.13.0, timeout-0.4.1, marcel-1.0.4, base64-0.2.0, bigdecimal-3.1.8, concurrent-ruby-1.3.4, connection_pool-2.4.1, drb-2.2.1, minitest-5.25.1, mutex_m-0.2.0, tzinfo-2.0.6, rackup-2.1.0, rake-13.2.1, thor-1.3.2, rdoc-6.7.0, io-console-0.7.2, net-http-0.4.1, mini_mime-1.1.5, multi_xml-0.7.1, dry-core-1.0.1, dry-inflector-1.1.0, dry-logic-1.5.0, websocket-extensions-0.1.5, date-3.3.4, net-protocol-0.2.2, loofah-2.22.0, webrick-1.8.1, psych-5.1.2, uri-0.13.1, crass-1.0.6, stringio-3.1.1 in locally installed gems (Bundler::GemNotFound) from /usr/local/lib/ruby/3.2.0/bundler/definition.rb:197:in
specs’
from /usr/local/lib/ruby/3.2.0/bundler/definition.rb:254:in specs_for' from /usr/local/lib/ruby/3.2.0/bundler/runtime.rb:18:in
setup’
from /usr/local/lib/ruby/3.2.0/bundler.rb:171:in setup' from /usr/local/lib/ruby/3.2.0/bundler/setup.rb:23:in
block in <top (required)>’
from /usr/local/lib/ruby/3.2.0/bundler/ui/shell.rb:159:in with_level' from /usr/local/lib/ruby/3.2.0/bundler/ui/shell.rb:111:in
silence’
from /usr/local/lib/ruby/3.2.0/bundler/setup.rb:23:in <top (required)>' from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in
require’
from internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb:85:in require' from /app/demo/config/boot.rb:3:in
<top (required)>’
from bin/rails:3:in require_relative' from bin/rails:3:in
’
It states that gems are not found but I’ve bundled installed on my docker file and during the build process it seems running the required gems files. I am completely lost guys can someone lead me to the right direction please.