Skip to content

Instantly share code, notes, and snippets.

@nerdinand
Created January 29, 2022 22:32
Show Gist options
  • Select an option

  • Save nerdinand/76405f5f5fb06ca7bd9cf367e4910a11 to your computer and use it in GitHub Desktop.

Select an option

Save nerdinand/76405f5f5fb06ca7bd9cf367e4910a11 to your computer and use it in GitHub Desktop.

Revisions

  1. nerdinand created this gist Jan 29, 2022.
    20 changes: 20 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    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"]
    9 changes: 9 additions & 0 deletions entrypoint.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    #!/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 "$@"

    3 changes: 3 additions & 0 deletions podman-build.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    #!/bin/bash

    podman build -t rails7:latest .
    3 changes: 3 additions & 0 deletions podman-run.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    #!/bin/bash

    podman run -p 3000:3000 rails7:latest