Created
July 28, 2018 06:20
-
-
Save saboyutaka/f7543e628b54f5bc8cf5a43d28c19ae2 to your computer and use it in GitHub Desktop.
Docker Compose for Rails
This file contains hidden or 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' | |
services: | |
web: | |
build: . | |
command: /bin/sh -c "rm -f /app/tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" | |
volumes: | |
- .:/app | |
- bundle-volume:/usr/local/bundle | |
ports: | |
- 3000:3000 | |
depends_on: | |
- db | |
- redis | |
tty: true | |
stdin_open: true | |
yarn: | |
build: | |
context: . | |
dockerfile: Dockerfile.yarn | |
volumes: | |
- .:/app | |
- node-modules-volume:/app/node_modules | |
db: | |
image: postgres:10-alpine | |
ports: | |
- 5432:5432 | |
environment: | |
POSTGRES_DB: rails_development | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
volumes: | |
- db-volume:/var/lib/postgresql/data | |
redis: | |
image: redis:4.0-alpine | |
ports: | |
- 6379:6379 | |
volumes: | |
bundle-volume: | |
db-volume: | |
node-modules-volume: |
This file contains hidden or 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.5.1 | |
ENV LANG C.UTF-8 | |
RUN apt-get update -qq && \ | |
apt-get install -y --no-install-recommends \ | |
build-essential \ | |
libpq-dev \ | |
libfontconfig1 \ | |
less \ | |
vim && \ | |
rm -rf /var/lib/apt/lists/* | |
WORKDIR /app | |
RUN bundle config --local build.nokogiri --use-system-libraries && \ | |
bundle config --local job 10 |
This file contains hidden or 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 node:9 | |
LABEL maintainer "saboyutaka<[email protected]>" | |
RUN mkdir -p /app | |
WORKDIR /app | |
RUN npm install -g npm && \ | |
npm install -g yarn | |
ENTRYPOINT ["yarn"] |
This file contains hidden or 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
.DEFAULT_GOAL := help | |
build: ## build develoment environment | |
if ! [ -f .env ];then cp .env.example .env;fi | |
docker-compose run --rm web bundle install | |
docker-compose run --rm yarn install | |
docker-compose run --rm yarn run dev | |
serve: up attach ## Run Serve | |
up: ## Run web container | |
docker-compose up -d web | |
console: ## Run Rails console | |
docker-compose run --rm web bundle exec rails c | |
bundle: ## Run bundle install | |
docker-compose run --rm web bundle install | |
attach: ## Attach running web container for binding.pry | |
docker attach `docker ps -f name=xxxxxx_web -f status=running --format "{{.ID}}"` | |
yarn_install: ## Run yarn install | |
docker-compose run --rm yarn install | |
yarn_dev: ## Run yarn run dev | |
docker-compose run --rm yarn run dev | |
yarn_watch: ## Run yarn watch | |
docker-compose run --rm yarn run watch | |
.PHONY: help | |
help: | |
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment