Skip to content

Instantly share code, notes, and snippets.

@rickyc
Last active February 26, 2018 20:22
Show Gist options
  • Save rickyc/eb291b505a1b1c34eaf5915573a0fe17 to your computer and use it in GitHub Desktop.
Save rickyc/eb291b505a1b1c34eaf5915573a0fe17 to your computer and use it in GitHub Desktop.
Basic Docker Compose to spin up a Ruby on Rails / Webpacker server.
  1. Install Docker
  2. Type docker-compose up to boot up the server.
  3. Navigate to http://localhost:3000 to view the application
  4. Type docker-compose exec web rails db:create to create a database.
  5. Type docker-compose exec web rails db:migrate to run migrations.
version: '3.2'
services:
db:
image: postgres:9.6-alpine
ports:
- 5432:5432
app: &app
build: .
volumes:
- .:/app
webpacker:
<<: *app
command: bundle exec bin/webpack-dev-server
environment:
- WEBPACKER_DEV_SERVER_HOST=0.0.0.0
ports:
- 8080:8080
web:
<<: *app
command: puma -C config/puma.rb
environment:
- RAILS_ENV=development
- WEBPACKER_DEV_SERVER_HOST=webpacker
ports:
- 3000:3000
depends_on:
- db
FROM ruby:2.4.2
RUN apt-get update -qq && apt-get install -y \
build-essential \
apt-transport-https \
apt-utils \
cmake \
libpq-dev
# for nokogiri
RUN apt-get install -y libxml2-dev libxslt1-dev
# for a JS runtime
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - \
&& apt-get install -y nodejs
# yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& apt-get install -y yarn
ENV APP_HOME /app
ADD . $APP_HOME
WORKDIR $APP_HOME
COPY . .
RUN bundle install
RUN yarn install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment