Add CI/CD
This commit is contained in:
3
Dockerfile
Normal file
3
Dockerfile
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
FROM httpd
|
||||||
|
|
||||||
|
COPY ./public/ /usr/local/apache2/htdocs/
|
||||||
45
Jenkinsfile
vendored
Normal file
45
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
node {
|
||||||
|
stage ("Checkout") {
|
||||||
|
checkout scm
|
||||||
|
}
|
||||||
|
|
||||||
|
stage ("Dependencies") {
|
||||||
|
npm ci
|
||||||
|
}
|
||||||
|
|
||||||
|
stage ("Build Gatsby") {
|
||||||
|
environment {
|
||||||
|
GATSBY_FIREBASE_API_KEY = credentials('FIREBASE_API_KEY')
|
||||||
|
GATSBY_AUTH_DOMAIN = spencassemble-sol-journal.firebaseapp.com
|
||||||
|
GATSBY_DATABASE_URL = https://spencassemble-sol-journal.firebaseio.com
|
||||||
|
GATSBY_PROJECT_ID = spencassemble-sol-journal
|
||||||
|
GATSBY_STORAGE_BUCKET = spencassemble-sol-journal.appspot.com
|
||||||
|
GATSBY_MESSAGING_SENDER_ID = 299522647169
|
||||||
|
GATSBY_APP_ID = 1:299522647169:web:fc74af44747fd7cef79980
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
npm run build
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
docker.withServer("ssh://rancher@192.168.1.116") {
|
||||||
|
docker.image("docker").withRun("") {
|
||||||
|
withCredentials([usernamePassword(credentialsId: "DockerHub", usernameVariable: "DOCKERUSER", passwordVariable: "DOCKERPASS")]) {
|
||||||
|
sh 'docker login -u "$DOCKERUSER" -p "$DOCKERPASS"'
|
||||||
|
}
|
||||||
|
|
||||||
|
stage ("Build Container") {
|
||||||
|
sh "docker image build -t spencerpincott/sol-journal:1.${env.BUILD_NUMBER} ."
|
||||||
|
}
|
||||||
|
|
||||||
|
stage ("Publish Container") {
|
||||||
|
sh "docker image push spencerpincott/sol-journal:1.${env.BUILD_NUMBER}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage ("Deploy") {
|
||||||
|
sh "ssh rancher@192.168.1.116 'docker stop sol-journal && docker rm sol-journal'"
|
||||||
|
sh "ssh rancher@192.168.1.116 'docker run -dit -p 5000:80 --name sol-journal --restart=always spencerpincott/sol-journal:1.${env.BUILD_NUMBER}'"
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user