docked
docked copied to clipboard
Starting Place (for esbuild environments)
Just wanted to share my docker-compose.yml file and Dockerfile that I use for development whenever I'm making new Rails applications. My preferred way is to use esbuild, so these are tailored to that. Hopefully it can be of some use.
# Dockerfile.dev
ARG RUBY_VERSION
FROM ruby:$RUBY_VERSION
RUN apt update -qq && apt upgrade -y
RUN apt install -y build-essential
RUN apt install -y postgresql-client
RUN curl -sL https://deb.nodesource.com/setup_19.x | bash -
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt update -qq
RUN apt install -y nodejs yarn
RUN gem update --system
RUN gem install bundle
WORKDIR /app
RUN echo 'gem: --no-rdoc --no-ri >> "$HOME/.gemrc"'
COPY Gemfile Gemfile.lock ./
COPY package.json yarn.lock ./
RUN bundle install -j $(nproc)
RUN yarn install
# docker-compose.yml
version: '3.8'
x-base: &base
build:
context: .
dockerfile: ./Dockerfile.dev
args:
RUBY_VERSION: '3.1.3'
stdin_open: true
tty: true
volumes:
- .:/app:cached
environment:
- DATABASE_URL=postgres://postgres:postgres@postgres:5432
depends_on:
- redis
- postgres
services:
app:
<<: *base
command: bin/rails server -p 3000 -b 0.0.0.0
ports:
- '3000:3000'
css:
<<: *base
command: yarn build:css --watch
js:
<<: *base
command: yarn build --watch
# sidekiq:
# <<: *base
# command: bundle exec sidekiq -C config/sidekiq.yml
redis:
image: redis:latest
restart: always
postgres:
image: postgres:14-alpine
volumes:
- postgres:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=postgres
ports:
- 5432
volumes:
postgres:
Additionally, I also modify the bin/dev with docker compose up
# bin/dev
#!/usr/bin/env bash
docker compose up