Hi all,
I just successfully deployed my application, however I am unable to run the rails:db seed with the command flyctl ssh console -C ‘/app/bin/rails db:seed’.
it return this error :
flyctl ssh console -C ‘/app/bin/rails db:seed’
Connecting to … … complete
fork/exec /app/bin/rails: no such file or directory
Can someone help me resolve this issue? thanks
my docker file :
# syntax = docker/dockerfile:1
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.0.3
FROM ruby:$RUBY_VERSION-slim as base
# Rails app lives here
WORKDIR /rails
# install git
RUN apt-get update && apt-get install -y git
# 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.3.7
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=16.14.2
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 yarn
ARG YARN_VERSION=1.22.15
RUN npm install -g yarn@$YARN_VERSION
# Install application gems
COPY Gemfile Gemfile.lock ./
RUN bundle _${BUNDLER_VERSION}_ install && \
bundle exec bootsnap precompile --gemfile
# Install node modules
COPY package.json yarn.lock .
RUN yarn install
# Copy application code
COPY . .
# 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 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"]
fly.toml :
# fly.toml file generated for jardica on 2023-01-30T17:46:01+01:00
app = "jardica"
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.rake :
# commands used to deploy a Rails application
namespace :fly do
# BUILD step:
# - changes to the filesystem made here DO get deployed
# - NO access to secrets, volumes, databases
# - Failures here prevent deployment
task :build => 'assets:precompile'
# RELEASE step:
# - changes to the filesystem made here are DISCARDED
# - full access to secrets, databases
# - failures here prevent deployment
task :release => 'db:migrate'
# SERVER step:
# - changes to the filesystem made here are deployed
# - full access to secrets, databases
# - failures here result in VM being stated, shutdown, and rolled back
# to last successful deploy (if any).
task :server => :swapfile do
sh 'bin/rails server'
end
# optional SWAPFILE task:
# - adjust fallocate size as needed
# - performance critical applications should scale memory to the
# point where swap is rarely used. 'fly scale help' for details.
# - disable by removing dependency on the :server task, thus:
# task :server do
task :swapfile do
sh 'fallocate -l 512M /swapfile'
sh 'chmod 0600 /swapfile'
sh 'mkswap /swapfile'
sh 'echo 10 > /proc/sys/vm/swappiness'
sh 'swapon /swapfile'
end
end