Add Docker Compose file

This commit is contained in:
Ivaylo Markov 2020-11-05 21:13:09 +02:00
parent 6bbd39dc23
commit 6386ae6db9
4 changed files with 49 additions and 0 deletions

27
docker-compose.yml Normal file
View File

@ -0,0 +1,27 @@
version: '3.7'
services:
app:
build:
context: ./docker/app
depends_on:
- db
env_file:
- "./docker/dev.env"
volumes:
- ./:/clarion
environment:
- BUNDLE_PATH=./vendor
working_dir: "/clarion"
command: "./docker/app/run.sh"
ports:
- 127.0.0.1:3000:3000
db:
image: postgres:11.9
volumes:
- clarion-db:/var/lib/postgresql/data
env_file:
- "./docker/dev.env"
volumes:
clarion-db:

3
docker/app/Dockerfile Normal file
View File

@ -0,0 +1,3 @@
FROM ruby:2.6.5
RUN apt-get update && apt-get install -y postgresql-client

13
docker/app/run.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
# Install dependencies
bundle install
# DB migrations
./bin/rails db:create
./bin/rails db:migrate
./bin/rails db:seed
# Remove leftover PID file from non-clean exit
rm tmp/pids/server.pid
./bin/rails server --binding=0.0.0.0

6
docker/dev.env Normal file
View File

@ -0,0 +1,6 @@
RAILS_ENV=development
POSTGRES_HOST=db
POSTGRES_USER=clarion
POSTGRES_PASSWORD=clarion
POSTGRES_DB=clarion