Update Jenkins with env and Dockerfile labels

This commit is contained in:
30hours 2024-02-16 02:34:52 +00:00
parent 0b6c085131
commit 257e889b0a
3 changed files with 15 additions and 14 deletions

View file

@ -1,5 +1,6 @@
FROM ubuntu:22.04 as blah2_env
LABEL maintainer="30hours <nathan@30hours.dev>"
LABEL org.opencontainers.image.source https://github.com/30hours/blah2
WORKDIR /blah2
ADD lib lib

23
Jenkinsfile vendored
View file

@ -3,8 +3,9 @@ pipeline {
environment {
GHCR_REGISTRY = "ghcr.io"
GHCR_USERNAME = credentials('30hours')
GHCR_TOKEN = credentials('ghcr-login')
BLAH2_NAME = "30hours/blah2"
BLAH2_API_NAME = "30hours/blah2_api"
}
stages {
@ -15,11 +16,9 @@ pipeline {
}
stage('Build') {
steps {
script {
echo 'Building the project'
blah2 = docker.build("30hours/blah2", "--file ./Dockerfile .")
blah2_api = docker.build("30hours/blah2", "--file ./api/Dockerfile ./api")
}
sh 'docker build -t $BLAH2_NAME .'
sh 'docker build -t $BLAH2_API_NAME --file ./api/Dockerfile ./api'
}
}
stage('Test') {
@ -29,14 +28,12 @@ pipeline {
}
stage('Push') {
steps {
script {
echo 'Pushing the application'
docker.withRegistry("${GHCR_REGISTRY}", "${GHCR_TOKEN}") {
blah2.push()
blah2_api.push()
}
}
sh 'echo $GHCR_TOKEN_PSW | docker login ghcr.io -u $GHCR_TOKEN_USR --password-stdin'
sh 'docker tag $BLAH2_NAME ghcr.io/$BLAH2_NAME'
sh 'docker tag $BLAH2_API_NAME ghcr.io/$BLAH2_API_NAME'
sh 'docker push ghcr.io/$BLAH2_NAME'
sh 'docker push ghcr.io/$BLAH2_API_NAME'
sh 'docker logout'
}
}
}

View file

@ -1,5 +1,8 @@
FROM node:16
LABEL maintainer="30hours <nathan@30hours.dev>"
LABEL org.opencontainers.image.source https://github.com/30hours/blah2
# Create app directory
WORKDIR /usr/src/app