Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby project using docker

My App

Running

Setup:

% docker-compose run --rm -u root web bash -c "mkdir -p /bundle/vendor && chown ruby /bundle/vendor"
% docker-compose run --rm web bundle install
% docker-compose run --rm web bundle exec rake db:setup

See setup.

Run:

% docker-compose up web

And go to localhost:3000.

version: "2"
services:
web:
build: .
volumes:
- .:/app
- bundle_path:/bundle
environment:
- BUNDLE_PATH=/bundle/vendor
- BUNDLE_APP_CONFIG=/app/.bundle
- BUNDLE_BIN=/bundle/vendor/bin
- GEM_HOME=/bundle/vendor
user: ruby
working_dir: /app
command: bundle exec puma -p 3000 config.ru
ports:
- "3000:3000"
links:
- db
db:
image: postgres
volumes:
- db:/var/lib/postgresql/data
expose:
- "5432"
volumes:
bundle_path:
db:
from ruby
env DEBIAN_FRONTEND=noninteractive \
NODE_VERSION=10.1.0
run sed -i "/deb-src/d" /etc/apt/sources.list && \
wget -q -O- https://dl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list && \
apt-get update && \
apt-get install -y build-essential libpq-dev postgresql-client google-chrome-stable && \
curl -sSL "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" | tar xfJ - -C /usr/local --strip-components=1 && \
npm install npm -g && \
wget -q -O- https://yarnpkg.com/latest.tar.gz | tar xfz - -C /opt && \
mv /opt/yarn-v* /opt/yarn && ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn && \
useradd -m -s /bin/bash -u 1000 ruby
source "https://rubygems.org"
gem "puma"
# gem "rails"
# gem "sinatra"
#!/bin/bash
set -xe
# Uncomment this line and ensure your config/database.yml.sample is ready to run with docker.
# cp config/database.yml.sample config/database.yml
docker-compose run --rm -u root web bash -c "mkdir -p /bundle/vendor && chown ruby /bundle/vendor"
docker-compose run --rm web bundle install
# Uncomment this line if you are using Ruby on Rails
# docker-compose run --rm web bundle exec rake db:create
# docker-compose run --rm web bundle exec rake db:migrate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment