From e8f0014f605d716ff609dbe8d65edb453f33abd3 Mon Sep 17 00:00:00 2001
From: Romain Lebbadi-Breteau <romain@lebbadi.fr>
Date: Sat, 12 Feb 2022 08:09:50 -0500
Subject: [PATCH] CICD deploy, php lint, docker-compose.prod

---
 .gitlab-ci.yml          |   3 +
 composer.json           |   1 +
 composer.lock           | 119 +++++++++++++++++++++++++++++++++++++++-
 docker-compose.prod.yml |  41 ++++++++++++++
 symfony.lock            |   6 ++
 5 files changed, 168 insertions(+), 2 deletions(-)
 create mode 100644 docker-compose.prod.yml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index fe26d0c9..dc9d3281 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -35,5 +35,8 @@ build_image:
   script:
   - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH -f docker/Dockerfile.prod .
   - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH
+  - mkdir ~/.ssh
+  - echo "ssh-ed25519 $SSH_KEY" > ~/.ssh/id_ed25519
+  - ssh -o StrictHostKeyChecking=no ubuntu@141.94.208.123 ./update.sh
   only:
   - main
diff --git a/composer.json b/composer.json
index db88b5bd..db5290cb 100644
--- a/composer.json
+++ b/composer.json
@@ -46,6 +46,7 @@
     },
     "require-dev": {
         "doctrine/doctrine-fixtures-bundle": "^3.4",
+        "overtrue/phplint": "^4.1",
         "phpunit/phpunit": "^9.5",
         "symfony/browser-kit": "6.0.*",
         "symfony/css-selector": "6.0.*",
diff --git a/composer.lock b/composer.lock
index 7b7311c5..ca36caa1 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "2bc584740bd8b5f4e13fa79a6da3369b",
+    "content-hash": "36120af3e8e726898d3266415ba189fe",
     "packages": [
         {
             "name": "doctrine/annotations",
@@ -7622,6 +7622,46 @@
             ],
             "time": "2020-11-13T09:40:50+00:00"
         },
+        {
+            "name": "n98/junit-xml",
+            "version": "1.1.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/cmuench/junit-xml.git",
+                "reference": "0017dd92ac8cb619f02e32f4cffd768cfe327c73"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/cmuench/junit-xml/zipball/0017dd92ac8cb619f02e32f4cffd768cfe327c73",
+                "reference": "0017dd92ac8cb619f02e32f4cffd768cfe327c73",
+                "shasum": ""
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^9.5.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "N98\\JUnitXml\\": "src/N98/JUnitXml"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Christian Münch",
+                    "email": "c.muench@netz98.de"
+                }
+            ],
+            "description": "JUnit XML Document generation library",
+            "support": {
+                "issues": "https://github.com/cmuench/junit-xml/issues",
+                "source": "https://github.com/cmuench/junit-xml/tree/1.1.0"
+            },
+            "time": "2020-12-25T09:08:58+00:00"
+        },
         {
             "name": "nikic/php-parser",
             "version": "v4.13.2",
@@ -7678,6 +7718,81 @@
             },
             "time": "2021-11-30T19:35:32+00:00"
         },
+        {
+            "name": "overtrue/phplint",
+            "version": "4.1.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/overtrue/phplint.git",
+                "reference": "b395e5016f454a0bb6757ad71901d2838f90ccc1"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/overtrue/phplint/zipball/b395e5016f454a0bb6757ad71901d2838f90ccc1",
+                "reference": "b395e5016f454a0bb6757ad71901d2838f90ccc1",
+                "shasum": ""
+            },
+            "require": {
+                "ext-json": "*",
+                "n98/junit-xml": "1.1.0",
+                "php": ">=8.0",
+                "symfony/console": "^5.3.11|^6.0",
+                "symfony/finder": "^5.3.7|^6.0",
+                "symfony/process": "^5.3.12|^6.0",
+                "symfony/yaml": "^5.3.11|^6.0"
+            },
+            "require-dev": {
+                "bamarni/composer-bin-plugin": "^1.4",
+                "brainmaestro/composer-git-hooks": "^2.8.5",
+                "friendsofphp/php-cs-fixer": "^3.4.0",
+                "jakub-onderka/php-console-highlighter": "^0.4",
+                "jetbrains/phpstorm-stubs": "^2021.3"
+            },
+            "bin": [
+                "bin/phplint"
+            ],
+            "type": "library",
+            "extra": {
+                "hooks": {
+                    "pre-commit": [
+                        "composer fix-style"
+                    ]
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Overtrue\\PHPLint\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "overtrue",
+                    "email": "anzhengchao@gmail.com"
+                }
+            ],
+            "description": "`phplint` is a tool that can speed up linting of php files by running several lint processes at once.",
+            "keywords": [
+                "check",
+                "lint",
+                "phplint",
+                "syntax"
+            ],
+            "support": {
+                "issues": "https://github.com/overtrue/phplint/issues",
+                "source": "https://github.com/overtrue/phplint/tree/4.1.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/overtrue",
+                    "type": "github"
+                }
+            ],
+            "time": "2021-12-23T21:26:28+00:00"
+        },
         {
             "name": "phar-io/manifest",
             "version": "2.0.3",
@@ -9840,5 +9955,5 @@
         "ext-iconv": "*"
     },
     "platform-dev": [],
-    "plugin-api-version": "2.2.0"
+    "plugin-api-version": "2.1.0"
 }
diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml
new file mode 100644
index 00000000..de7246ce
--- /dev/null
+++ b/docker-compose.prod.yml
@@ -0,0 +1,41 @@
+version: '3'
+
+services:
+###> doctrine/doctrine-bundle ###
+  database:
+    image: postgres:${POSTGRES_VERSION:-13}-alpine
+    environment:
+      POSTGRES_DB: ${POSTGRES_DB:-app}
+      # You should definitely change the password in production
+      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-ChangeMe}
+      POSTGRES_USER: ${POSTGRES_USER:-symfony}
+    volumes:
+      - db-data:/var/lib/postgresql/data:rw
+    networks:
+      - default
+      # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
+      # - ./docker/db/data:/var/lib/postgresql/data:rw
+###< doctrine/doctrine-bundle ###
+
+  web:
+    image: registry.git.step.polymtl.ca:443/caillou-roches-hackatown/calendrier
+    build:
+      context: .
+      dockerfile: docker/Dockerfile.prod
+    labels:
+      traefik.enable: true
+      traefik.http.routers.calendrier.rule: "Host(`calendar-hackatown.step.polymtl.ca`)"
+      traefik.http.routers.calendrier.tls: true
+      traefik.http.routers.calendrier.tls.certresolver: default
+    networks:
+      - default
+      - traefik_default
+
+volumes:
+###> doctrine/doctrine-bundle ###
+  db-data:
+###< doctrine/doctrine-bundle ###
+
+networks:
+  traefik_default:
+    external: true
diff --git a/symfony.lock b/symfony.lock
index 744baab5..1b7e71f4 100644
--- a/symfony.lock
+++ b/symfony.lock
@@ -107,9 +107,15 @@
     "myclabs/deep-copy": {
         "version": "1.10.2"
     },
+    "n98/junit-xml": {
+        "version": "1.1.0"
+    },
     "nikic/php-parser": {
         "version": "v4.13.2"
     },
+    "overtrue/phplint": {
+        "version": "4.1.0"
+    },
     "phar-io/manifest": {
         "version": "2.0.3"
     },
-- 
GitLab