Skip to content

Instantly share code, notes, and snippets.

@dmitryrck
Last active June 26, 2022 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dmitryrck/ff2633acfffcba1bef593bdfade4d557 to your computer and use it in GitHub Desktop.
Save dmitryrck/ff2633acfffcba1bef593bdfade4d557 to your computer and use it in GitHub Desktop.
Ruby project using docker. This is a boilerplate, for instructions see https://dmitryrck.com/zero-to-up-and-running-ruby-project/

My App

Running

Setup:

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

See setup.

Run:

$ docker-compose up app

And go to localhost:3000.

version: "2"
services:
app:
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 app bash -c "mkdir -p /bundle/vendor && chown ruby /bundle/vendor"
docker-compose run --rm app bundle install
# Uncomment this line if you are using Ruby on Rails
# docker-compose run --rm app bundle exec rake db:create
# docker-compose run --rm app bundle exec rake db:migrate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment