From 34936c5c31cfd723a635fb4870b33906856c4d3c Mon Sep 17 00:00:00 2001
From: Perreal Guillaume <guillaume.perreal@irstea.fr>
Date: Wed, 29 May 2019 15:07:00 +0200
Subject: [PATCH] dev|test: configuration pour servir l'appli avec Docker.

---
 .dockerignore |  4 ++++
 Dockerfile    | 22 ++++++++++++++++++++++
 composer.json |  4 +++-
 3 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 .dockerignore
 create mode 100644 Dockerfile

diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..384d575
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,4 @@
+/*
+!/composer.*
+!/src
+!/tests
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..0c92e76
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,22 @@
+FROM composer:1.8 AS vendors
+
+RUN composer global req hirak/prestissimo
+
+ADD composer.* ./
+
+RUN composer install
+
+FROM php:7.1
+
+ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64  /usr/local/bin/dumb-init
+RUN chmod +x /usr/local/bin/dumb-init
+ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]
+
+RUN mkdir /app
+WORKDIR /app
+
+COPY --from=vendors /app/vendor ./vendor
+COPY src ./src
+COPY tests ./tests
+
+CMD ["/usr/local/bin/php", "tests/console", "server:run", "0.0.0.0:80"]
diff --git a/composer.json b/composer.json
index 0ffdcdd..c0157ec 100644
--- a/composer.json
+++ b/composer.json
@@ -116,7 +116,9 @@
     "test:composer-validate": "composer validate",
     "test:composer-require": "vendor/bin/composer-require-checker check",
     "test:security": "test '!' -s composer.lock || vendor/bin/security-checker security:check",
-    "test:console": "@php tests/console"
+    "test:console": "@php tests/console",
+    "dev:serve": "tests/console server:run -v",
+    "dev:docker-serve": "docker run --rm -v \"$PWD/src:/app/src:ro\" -v \"$PWD/tests:/app/tests:ro\" $(docker build . -q)"
   },
   "scripts-descriptions": {
     "fix-cs": "Applique les corrections automatiques de style.",
-- 
GitLab