Skip to content

Instantly share code, notes, and snippets.

@nerdinand
Created January 29, 2022 22:32
Show Gist options
  • Save nerdinand/76405f5f5fb06ca7bd9cf367e4910a11 to your computer and use it in GitHub Desktop.
Save nerdinand/76405f5f5fb06ca7bd9cf367e4910a11 to your computer and use it in GitHub Desktop.
Podman setup for Rails 7 (without compose or database)
FROM ruby:3.1
# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1
WORKDIR /usr/src/app
COPY Gemfile Gemfile.lock ./
RUN bundle install
# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
COPY . .
EXPOSE 3000
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
#!/bin/bash
set -e
# Remove a potentially pre-existing server.pid for Rails.
rm -f /myapp/tmp/pids/server.pid
# Then exec the container's main process (what's set as CMD in the Dockerfile).
exec "$@"
#!/bin/bash
podman build -t rails7:latest .
#!/bin/bash
podman run -p 3000:3000 rails7:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment