From 5df6c9f168989735ec98416f3bd6821786a94f48 Mon Sep 17 00:00:00 2001
From: Benjamin Bertrand <benjamin.bertrand@esss.se>
Date: Mon, 21 Aug 2017 11:14:30 +0200
Subject: [PATCH] Create .env file to store default compose variables

- add build instruction to docker-compose.yml
---
 .dockerignore      | 1 +
 .env               | 4 ++++
 .gitignore         | 1 +
 README.rst         | 5 ++---
 docker-compose.yml | 7 ++++---
 5 files changed, 12 insertions(+), 6 deletions(-)
 create mode 100644 .env

diff --git a/.dockerignore b/.dockerignore
index c767d4a..ab16628 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -3,3 +3,4 @@
 __pycache__
 settings*.cfg
 client
+data
diff --git a/.env b/.env
new file mode 100644
index 0000000..8aff1d7
--- /dev/null
+++ b/.env
@@ -0,0 +1,4 @@
+POSTGRES_USER=ics
+POSTGRES_PASSWORD=icspwd
+POSTGRES_DB=inventory_db
+PGDATA_VOLUME=./data/dev
diff --git a/.gitignore b/.gitignore
index 5808abb..ea8b9bb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
 __pycache__
 *.pyc
 settings*.cfg
+/data
diff --git a/README.rst b/README.rst
index 799e2bc..f6f4d2b 100644
--- a/README.rst
+++ b/README.rst
@@ -11,10 +11,9 @@ You can use docker for development:
 
 1. Clone the repository
 
-2. Create the database::
+2. Create the database. Data will be stored under "./data" by default.
+   You can export the PGDATA_VOLUME variable to use another directory::
 
-    $ mkdir /data/pgdata
-    $ export PGDATA_VOLUME=/data/pgdata
     # Start only postgres so it has time to initialize
     $ docker-compose up -d postgres
     # Create the database
diff --git a/docker-compose.yml b/docker-compose.yml
index 871c82a..3f23782 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -3,6 +3,7 @@ services:
   web:
     image: inventory
     container_name: inventory_web
+    build: .
     environment:
       LOCAL_SETTINGS: /app/settings.cfg
       FLASK_APP: /app/wsgi.py
@@ -22,7 +23,7 @@ services:
     volumes:
       - ${PGDATA_VOLUME}:/var/lib/postgresql/data/pgdata
     environment:
-      POSTGRES_USER: ics
-      POSTGRES_PASSWORD: icspwd
-      POSTGRES_DB: inventory_db
+      POSTGRES_USER: ${POSTGRES_USER}
+      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
+      POSTGRES_DB: ${POSTGRES_DB}
       PGDATA: /var/lib/postgresql/data/pgdata
-- 
GitLab