From 6386ae6db9b96e5bd59dfb1c07d20529ada734f6 Mon Sep 17 00:00:00 2001 From: Ivaylo Markov Date: Thu, 5 Nov 2020 21:13:09 +0200 Subject: [PATCH] Add Docker Compose file --- docker-compose.yml | 27 +++++++++++++++++++++++++++ docker/app/Dockerfile | 3 +++ docker/app/run.sh | 13 +++++++++++++ docker/dev.env | 6 ++++++ 4 files changed, 49 insertions(+) create mode 100644 docker-compose.yml create mode 100644 docker/app/Dockerfile create mode 100755 docker/app/run.sh create mode 100644 docker/dev.env 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