Last active
May 3, 2024 12:03
-
-
Save frankyston/a39283741c3f18c211052b07a207a372 to your computer and use it in GitHub Desktop.
Exemplo de docker compose para rails + sidekiq + redis + banco de dados
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "2" | |
services: | |
app: | |
build: | |
context: . | |
container_name: my_container | |
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" | |
volumes: | |
- .:/usr/src/app | |
- my_bundle:/usr/local/bundle | |
ports: | |
- 3000:3000 | |
stdin_open: true | |
tty: true | |
env_file: | |
- ${ENV_FILE:-.env} | |
depends_on: | |
- db | |
db: | |
image: postgres | |
container_name: my_db | |
volumes: | |
- pg_data:/var/lib/postgresql/data | |
environment: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
ports: | |
- "5432:5432" | |
sidekiq: | |
image: my_app # aqui é o nome da imagem que é gerado do serviço app | |
container_name: my_sidekiq | |
tty: true | |
stdin_open: true | |
depends_on: | |
- app | |
- db | |
- redis | |
volumes: | |
- .:/app | |
- my_bundle:/usr/local/bundle | |
command: bundle exec sidekiq -C config/sidekiq.yml | |
redis: | |
image: redis:7.0.10-alpine | |
container_name: my_redis | |
command: redis-server | |
volumes: | |
- redis_data:/data | |
ports: | |
- "6379:6379" | |
logging: | |
driver: none | |
mailcatcher: | |
restart: on-failure | |
image: dockage/mailcatcher:0.8.2 | |
ports: | |
- "1080:1080" | |
- "1025:1025" | |
volumes: | |
pg_data: | |
my_bundle: | |
redis_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ruby:3.1.2 | |
ARG NODE_MAJOR_VERSION=20 | |
RUN curl -sL https://deb.nodesource.com/setup_$NODE_MAJOR_VERSION.x | bash - | |
RUN apt-get update -qq && \ | |
apt-get install -y build-essential libvips nodejs libpq-dev postgresql-client && \ | |
apt-get clean && \ | |
rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man && \ | |
npm install -g yarn | |
RUN mkdir /usr/src/app | |
WORKDIR /usr/src/app | |
ADD . /usr/src/app | |
RUN gem install bundler -v 2.3.26 | |
RUN bundle install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment