From 16c45a36d298baee56b56b293f0ea1cb8f55567d Mon Sep 17 00:00:00 2001 From: Dillon Date: Tue, 26 Sep 2023 20:24:15 +0800 Subject: [PATCH] Jenkins Vapor initial commit --- .gitignore | 3 +++ Jenkinsfile | 49 +++++++++++++++++++++++++++++++++++++++++++ composer.json | 1 + production.Dockerfile | 3 +++ staging.Dockerfile | 3 +++ vapor.yml | 25 ++++++++++++++++++++++ 6 files changed, 84 insertions(+) create mode 100644 Jenkinsfile create mode 100644 production.Dockerfile create mode 100644 staging.Dockerfile create mode 100644 vapor.yml diff --git a/.gitignore b/.gitignore index 00c3679e..67451c2b 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ package-lock.json public/* /public/* storage/framework/laravel-excel/* +.vapor/ +.env.production +.env.staging diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..6fbf0385 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,49 @@ +// Webhook + Gitlab git pull + Vapor + +def payload = readJSON text: "${payload}" +String userName = payload.user_name +String userEmail = payload.user_email +String httpUrl = payload.project.http_url + + +pipeline { + agent { + docker { + image 'dillonngo/docker-based-image:poc' + args "--group-add 992 -v /var/run/docker.sock:/var/run/docker.sock" + } + } + environment { + HOME = '.' + } + stages { + stage('Download source code from Git') { + steps { + git( + url: httpUrl, + credentialsId: 'gitlab-jenkins-localhost', + branch: 'dillon/34-jenkins-vapor' + ) + } + } + + stage('Install') { + steps { + sh 'composer update' + } + } + + stage('Tests') { + steps { + sh 'vendor/bin/phpunit tests/Unit' + } + } + + stage('Deploy') { + steps { + sh 'vendor/bin/vapor deploy production --message="Test Jenkins"' + } + } + + } +} diff --git a/composer.json b/composer.json index af20f32d..95ea1ae2 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "intervention/image": "^2.5", "laravel/framework": "^8.40", "laravel/tinker": "^2.5", + "laravel/vapor-core": "^2.33", "maatwebsite/excel": "^3.1", "rinvex/countries": "^6.1", "spatie/laravel-activitylog": "^3.14", diff --git a/production.Dockerfile b/production.Dockerfile new file mode 100644 index 00000000..53dee762 --- /dev/null +++ b/production.Dockerfile @@ -0,0 +1,3 @@ +FROM laravelphp/vapor:php74 + +COPY . /var/task diff --git a/staging.Dockerfile b/staging.Dockerfile new file mode 100644 index 00000000..53dee762 --- /dev/null +++ b/staging.Dockerfile @@ -0,0 +1,3 @@ +FROM laravelphp/vapor:php74 + +COPY . /var/task diff --git a/vapor.yml b/vapor.yml new file mode 100644 index 00000000..6ad2cdc2 --- /dev/null +++ b/vapor.yml @@ -0,0 +1,25 @@ +id: 52493 +name: shipping-portal +environments: + production: + memory: 1024 + cli-memory: 512 + database: vapor-laravel-poc-db + storage: shipping-portal-production + runtime: 'docker' + timeout: 180 + build: + - 'composer update' + - 'npm install' + - 'npm run dev' + - 'gulp build' + deploy: + - 'php artisan migrate --force' + # staging: + # memory: 1024 + # cli-memory: 512 + # runtime: 'php-8.2:al2' + # build: + # - 'COMPOSER_MIRROR_PATH_REPOS=1 composer install' + # - 'php artisan event:cache' + # - 'npm ci && npm run dev && rm -rf node_modules'