Layerfile
#This is an example webapp.io configuration for rails!
FROM vm/ubuntu:18.04

# To note: Layerfiles create entire VMs, *not* containers!

# Install postgresql and run it in the background
RUN apt-get update && \\
  apt-get install postgresql postgresql-contrib libpq-dev

# install rails dependencies
RUN curl -fSsL https://deb.nodesource.com/setup_14.x | bash && \\
  curl -fSsL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \\
  echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \\
  apt-get update && \\
  apt-get install git-core zlib1g-dev build-essential libssl-dev \\
  libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev \\
  libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn

RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv
ENV PATH=$HOME/.rbenv/bin:$PATH
RUN echo 'eval "$(rbenv init -)"' >> ~/.bashrc

RUN git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
RUN echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc

RUN rbenv install 2.7.1
ENV PATH=$HOME/.rbenv/versions/2.7.1/bin:$PATH

RUN gem install pg rails


ENV RAILS_ENV=development

RUN sudo -u postgres createuser -s -i -d -r -l -w root
RUN sudo -u postgres -H -- psql -t -c "CREATE DATABASE mydb;"
RUN sudo -u postgres -H -- psql -c "ALTER ROLE root WITH PASSWORD 'password';"

# Copy your rails app into the runner
COPY . .

# set up database
RUN echo -e 'development:\\n\\
adapter: postgresql\\n\\
encoder: unicode\\n\\
database: mydb\\n\\
username: root\\n\\
password: password\\n' > config/database.yml


# run migrations
RUN bundle install
RUN bundle exec rake db:migrate
RUN bundle exec rake db:setup

# Start the server
RUN BACKGROUND rails server --binding 0.0.0.0
EXPOSE WEBSITE localhost:3000

Try this example live