Skip to content

Instantly share code, notes, and snippets.

@leandro-novaes
Last active February 29, 2024 13:07
Show Gist options
  • Save leandro-novaes/64ffa2c3585c48243074aaa53ceb0e66 to your computer and use it in GitHub Desktop.
Save leandro-novaes/64ffa2c3585c48243074aaa53ceb0e66 to your computer and use it in GitHub Desktop.
Docker: Ruby + Rails + Postgres + Elasticsearch + Redis + Sidekiq + Mailcatcher
version: "3"
services:
postgres:
image: "postgres:11.4-alpine"
restart: always
ports:
- '5432:5432'
volumes:
- postgres:/var/lib/postgresql/data
networks:
- backend
sidekiq:
build: .
restart: always
command: bundle exec sidekiq
networks:
- backend
redis:
image: redis:5.0.5-alpine
restart: always
command: redis-server
ports:
- '6379:6379'
volumes:
- redis:/var/lib/redis/data
networks:
- backend
elasticsearch:
image: elasticsearch:7.3.0
restart: always
ports:
- "9200:9200"
volumes:
- elasticsearch:/usr/share/elasticsearch/data
networks:
- backend
mailcatcher:
image: yappabe/mailcatcher
ports:
- "1025:1025"
- "1080:1080"
networks:
- backend
app:
build: .
restart: always
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
ports:
- "3000:3000"
volumes:
- .:/my-app
networks:
- backend
volumes:
postgres:
redis:
elasticsearch:
networks:
backend:
driver: "bridge"
FROM ruby:2.6.3-slim
RUN apt-get update && apt-get install -qq -y --no-install-recommends build-essential libpq-dev libsqlite3-dev curl imagemagick nodejs
RUN groupadd -r -g 1000 docker && \
useradd -r --create-home -u 1000 -g docker docker
WORKDIR /my-app
COPY Gemfile /my-app/Gemfile
COPY Gemfile.lock /my-app/Gemfile.lock
RUN chown -R docker:docker /my-app && \
chmod g+w /my-app/Gemfile.lock
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
USER docker
RUN gem install mailcatcher && \
bundle install
COPY . /my-app
CMD ["rails", "server", "-b", "0.0.0.0"]
#!/bin/bash
set -e
rm -f /my-app/tmp/pids/server.pid
exec "$@"
source 'https://rubygems.org'
gem 'rails', '~> 5.2', '>= 5.2.3'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment