diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..498559e --- /dev/null +++ b/docker-compose.yml @@ -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: \ No newline at end of file diff --git a/docker/app/Dockerfile b/docker/app/Dockerfile new file mode 100644 index 0000000..9ab8be8 --- /dev/null +++ b/docker/app/Dockerfile @@ -0,0 +1,3 @@ +FROM ruby:2.6.5 + +RUN apt-get update && apt-get install -y postgresql-client \ No newline at end of file diff --git a/docker/app/run.sh b/docker/app/run.sh new file mode 100755 index 0000000..b6d920d --- /dev/null +++ b/docker/app/run.sh @@ -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 \ No newline at end of file diff --git a/docker/dev.env b/docker/dev.env new file mode 100644 index 0000000..83d4e59 --- /dev/null +++ b/docker/dev.env @@ -0,0 +1,6 @@ +RAILS_ENV=development + +POSTGRES_HOST=db +POSTGRES_USER=clarion +POSTGRES_PASSWORD=clarion +POSTGRES_DB=clarion \ No newline at end of file