Create a Dockerfile in the root directory of your Sinatra project.
Add the following content to the Dockerfile:
# Use the official Ruby base image
FROM ruby:2.7
# Set the working directory
WORKDIR /app
# Copy the Gemfile and Gemfile.lock
COPY Gemfile Gemfile.lock ./
# Install dependencies
RUN bundle install --without development test
# Copy the application code
COPY . .
# Set the default command to run the Sinatra application
CMD ["ruby", "app.rb"]
This Dockerfile sets up a Ruby 2.7 environment, installs the dependencies using bundle install, and copies the application code to the /app directory. It then sets the default command to run the Sinatra application by executing ruby app.rb.
This Dockerfile sets up a Ruby 2.7 environment, installs the dependencies using bundle install, and copies the application code to the /app directory. It then sets the default command to run the Sinatra application by executing ruby app.rb.