diff --git a/.dockerignore b/.dockerignore
index ab16628810d678575aa5a080b143577b7f5bf625..bfa3cc385795299ee09618d7b4cb6ca002aba5d3 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,6 +1,10 @@
 .git
-*.swp
-__pycache__
+**/*.swp
+**/__pycache__
 settings*.cfg
 client
 data
+postgres
+Jenkinsfile
+Makefile
+docker-compose*.yml
diff --git a/.env b/.env
index 8aff1d7478c383e23064c6167b612857c084de20..b6c313d930357154a23de1d2203de0cab62a0836 100644
--- a/.env
+++ b/.env
@@ -1,4 +1,4 @@
 POSTGRES_USER=ics
 POSTGRES_PASSWORD=icspwd
 POSTGRES_DB=inventory_db
-PGDATA_VOLUME=./data/dev
+PGDATA_VOLUME=./data
diff --git a/Jenkinsfile b/Jenkinsfile
index 655d80165e0efeffa4cb9c5318a5d2b29279f2f8..98c2a9ba5d54d29f40a4d664f01b1b46396902ec 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -22,10 +22,10 @@ pipeline {
         }
         stage('Test') {
             steps {
-                sh 'make db_test'
+                sh 'make db_image'
                 /* let the time to postgres to start */
                 sh 'sleep 5'
-                sh 'make test'
+                sh 'make test_image'
             }
         }
         stage('Push') {
diff --git a/Makefile b/Makefile
index 4de5afef661ec5be8bfffbc36199c34f30e7ce1d..b4656cf6a7cbf847dfee4a3b314158c246617059 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-.PHONY: help build tag push refresh release db_dev initdb db_test test
+.PHONY: help build tag push refresh release db initdb test db_image test_image
 
 OWNER := europeanspallationsource
 GIT_TAG := $(shell git describe --always)
@@ -24,7 +24,7 @@ push: ## push the latest and git tag image
 
 clean: ## remove the image with git tag and the test database
 	-docker rmi $(OWNER)/$(IMAGE):$(GIT_TAG)
-	-docker rm -f inventory_postgres_test
+	-docker rm -f inventory_postgres
 
 refresh: ## pull the latest image from Docker Hub
 # skip if error: image might not be on dockerhub yet
@@ -36,14 +36,19 @@ release: refresh \
 	push
 release: ## build, tag, and push all stacks
 
-db_dev: ## start postgres for development
+db: ## start postgres for development
 	docker-compose up -d postgres
 
 initdb: ## initialize the dev database
 	docker-compose run --rm web flask initdb
 
-db_test: ## start postgres for test
-	docker-compose -f docker-compose-test.yml up -d postgres_test
+test:  ## run the tests (on current directory)
+	docker-compose run --rm web pytest --cov=app -v
 
-test:  ## run the tests
-	docker-compose -f docker-compose-test.yml run --rm web_test
+db_image: ## start postgres to test the latest image
+# Pass docker-compose.yml to skip docker-compose.override.yml
+	docker-compose -f docker-compose.yml up -d postgres
+
+test_image:  ## run the tests (on the latest image)
+# Pass docker-compose.yml to skip docker-compose.override.yml
+	docker-compose -f docker-compose.yml run --rm web
diff --git a/README.rst b/README.rst
index 89f675c51b730d59ea47ab664660cca87f67b1af..68e6022ceba025b18b275f829042817a8c9cb9be 100644
--- a/README.rst
+++ b/README.rst
@@ -11,14 +11,14 @@ You can use docker for development:
 
 1. Clone the repository
 
-2. Create the database. Data will be stored under "./data/dev" by default.
+2. Create the database. Data will be stored under "./data" by default.
    You can export the PGDATA_VOLUME variable to use another directory::
 
     # Start only postgres so it has time to initialize
     $ docker-compose up -d postgres
     or
-    $ make db_dev
-    # Create the database
+    $ make db
+    # Initialize the database
     $ docker-compose run --rm web flask initdb
     or
     $ make initdb
@@ -30,25 +30,37 @@ You can use docker for development:
 4. Open your browser and go to `http://localhost:8000
    <http://localhost:8000>`_.
 
+5. To run the tests::
+
+    $ make test
+
 
 Once the database has been created, you only need to run `docker-compose
 up` to start the app.
 
+
 Testing
 -------
 
-1. Create the database. Data will be stored under "./data/test"::
+By default docker-compose reads both docker-compose.yml and docker-compose.override.yml.
+In docker-compose.override.yml, the current directory is mounted as a volume.
+This is great for development.
+
+To test the built image, we should only use the docker-compose.yml (and ignore
+docker-compose.override.yml).
+
+1. Create the database::
 
     # Start only postgres so it has time to initialize
-    $ docker-compose -f docker-compose-test.yml up -d postgres_test
+    $ docker-compose -f docker-compose.yml up -d postgres
     or
-    $ make db_test
+    $ make db_image
 
 2. Run the tests::
 
-    $ docker-compose -f docker-compose-test.yml run --rm web_test
+    $ docker-compose -f docker-compose.yml run --rm web
     or
-    $ make test
+    $ make test_image
 
 
 Backup & restore
diff --git a/docker-compose-test.yml b/docker-compose-test.yml
deleted file mode 100644
index ed71ab40e7542107cc88e21927a15d06ce92eb08..0000000000000000000000000000000000000000
--- a/docker-compose-test.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-version: '2'
-services:
-  web_test:
-    image: europeanspallationsource/ics-inventory:latest
-    container_name: inventory_web_test
-    build: .
-    command: pytest --cov=app -v
-    volumes:
-      - .:/app
-    depends_on:
-      - postgres_test
-  postgres_test:
-    image: postgres:9.6
-    container_name: inventory_postgres_test
-    expose:
-      - "5432"
-    environment:
-      POSTGRES_USER: ics
-      POSTGRES_PASSWORD: icstest
-      POSTGRES_DB: inventory_db_test
-      PGDATA: /var/lib/postgresql/data/pgdata
diff --git a/docker-compose.override.yml b/docker-compose.override.yml
new file mode 100644
index 0000000000000000000000000000000000000000..2551d30c3301150a95cbfbe7987f5c3dee061672
--- /dev/null
+++ b/docker-compose.override.yml
@@ -0,0 +1,19 @@
+version: '2'
+services:
+  web:
+    build: .
+    environment:
+      LOCAL_SETTINGS: /app/settings.cfg
+      FLASK_APP: /app/wsgi.py
+      FLASK_DEBUG: 1
+    command: flask run --host 0.0.0.0 --port 8000
+    ports:
+      - "8000:8000"
+    volumes:
+      - .:/app
+  postgres:
+    ports:
+      - "5432:5432"
+    volumes:
+      - ./postgres/create-test-db.sh:/docker-entrypoint-initdb.d/create-test-db.sh
+      - ${PGDATA_VOLUME}:/var/lib/postgresql/data/pgdata
diff --git a/docker-compose.yml b/docker-compose.yml
index d6f7922f3b1d85d5353f09c05ca37a420902a527..3d94e0183c6a0028702c7501ec7a4507e24d8fec 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -3,25 +3,16 @@ services:
   web:
     image: europeanspallationsource/ics-inventory:latest
     container_name: inventory_web
-    build: .
-    environment:
-      LOCAL_SETTINGS: /app/settings.cfg
-      FLASK_APP: /app/wsgi.py
-      FLASK_DEBUG: 1
-    command: flask run --host 0.0.0.0 --port 8000
-    ports:
-      - "8000:8000"
-    volumes:
-      - .:/app
+    command: pytest --cov=app -v
     depends_on:
       - postgres
   postgres:
     image: postgres:9.6
     container_name: inventory_postgres
-    ports:
-      - "5432:5432"
+    expose:
+      - "5432"
     volumes:
-      - ${PGDATA_VOLUME}:/var/lib/postgresql/data/pgdata
+      - ./postgres/create-test-db.sh:/docker-entrypoint-initdb.d/create-test-db.sh
     environment:
       POSTGRES_USER: ${POSTGRES_USER}
       POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
diff --git a/postgres/create-test-db.sh b/postgres/create-test-db.sh
new file mode 100755
index 0000000000000000000000000000000000000000..da67a988c84d63c23fb90b741adc980aa9fe4868
--- /dev/null
+++ b/postgres/create-test-db.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+set -e
+
+psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" -d "$POSTGRES_DB" <<-EOSQL
+    CREATE DATABASE inventory_db_test;
+EOSQL
diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py
index 2147fdbff7a47300f6559b5e00b9162594c1fc7e..cd74317ee0d2991e650675aa7d81e896c52675eb 100644
--- a/tests/functional/conftest.py
+++ b/tests/functional/conftest.py
@@ -22,7 +22,7 @@ def app(request):
     config = {
         'TESTING': True,
         'WTF_CSRF_ENABLED': False,
-        'SQLALCHEMY_DATABASE_URI': 'postgresql://ics:icstest@postgres_test/inventory_db_test',
+        'SQLALCHEMY_DATABASE_URI': 'postgresql://ics:icspwd@postgres/inventory_db_test',
         'INVENTORY_LDAP_GROUPS': {
             'admin': 'Inventory Admin',
             'create': 'Inventory User',