Skip to content

Instantly share code, notes, and snippets.

@HooFoo
Created April 5, 2024 10:15
Show Gist options
  • Select an option

  • Save HooFoo/96a3c2f8c9740480a4e2a5d3065af74d to your computer and use it in GitHub Desktop.

Select an option

Save HooFoo/96a3c2f8c9740480a4e2a5d3065af74d to your computer and use it in GitHub Desktop.
Compose profile for rails app with webpack, ngrok, PostgreSQL.
version: "3.9"
services:
db:
image: postgres
volumes:
- ./tmp/db:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: password
POSTGRES_USER: postgres
web:
build: .
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/myapp:cached
ports:
- "80:3000"
depends_on:
- db
expose:
- "3000"
webpack:
build: .
command: ./bin/webpack-dev-server
volumes:
- .:/myapp:cached
ngrok:
image: shkoliar/ngrok:latest
ports:
- "4551:4551"
links:
- web
depends_on:
- web
environment:
- DOMAIN=web
- PORT=3000
- AUTH_TOKEN=${NGROK_AUTHTOKEN}
# syntax=docker/dockerfile:1
FROM ruby:3.0
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client npm
RUN npm install -g yarn
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
RUN yarn
# 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"]
EXPOSE 3000
# Configure the main process to run when running the image
CMD ["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 "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment