- Install Docker
- Type
docker-compose up
to boot up the server. - Navigate to http://localhost:3000 to view the application
- Type
docker-compose exec web rails db:create
to create a database. - Type
docker-compose exec web rails db:migrate
to run migrations.
Last active
February 26, 2018 20:22
-
-
Save rickyc/eb291b505a1b1c34eaf5915573a0fe17 to your computer and use it in GitHub Desktop.
Basic Docker Compose to spin up a Ruby on Rails / Webpacker server.
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: '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 |
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: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