-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
50 lines (50 loc) · 1.26 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
pipeline {
environment {
registry = 'reg.laravel.pt'
imageName = 'frontend'
}
agent any
stages {
stage('php dependencies') {
steps {
script {
def composer = docker.image('composer:2')
def php = docker.image('php:7.4-fpm')
php.pull()
composer.pull()
composer.inside {
// to remove the need for the ignore, lets make our base image.
sh "composer install --ignore-platform-reqs"
}
php.inside {
sh "cp .env.example .env"
sh "php artisan key:generate"
}
}
}
}
stage('Building image') {
steps{
script {
dockerImage = docker.build("$registry/$imageName:$BUILD_NUMBER")
docker.withRegistry("https://$registry") {
dockerImage.push("$BUILD_NUMBER")
dockerImage.push("latest")
}
}
}
}
stage('Deploy in production') {
steps {
sshagent ( credentials: ['artisanpt-ssh']) {
sh '''ssh -v -o StrictHostKeyChecking=no -l root 178.62.209.5 << EOL
pwd
whoami
cd laravel.pt
TAG=$BUILD_NUMBER docker-compose up -d
'''
}
}
}
}
}