Compare commits

...

10 Commits

Author SHA1 Message Date
13b778a4e4 fix(ci): add default deploy credential and host variables to Jenkins pipeline 2026-03-06 15:42:18 +00:00
69c051052d Merge pull request 'swapped runner to node:20-bookworm-slim' (#38) from fix/update-runner into master
Reviewed-on: http://gitea.lan:3000/robbond/pleskSaas/pulls/38
2026-03-06 14:13:39 +00:00
d1982f1618 swapped runner to node:20-bookworm-slim 2026-03-06 14:13:26 +00:00
d2b57c03b3 Merge pull request 'changed image to node:20-bookworm-slim' (#37) from fix/update-docker-file-for-image into master
Reviewed-on: http://gitea.lan:3000/robbond/pleskSaas/pulls/37
2026-03-06 14:11:32 +00:00
5990ad9423 changed image to node:20-bookworm-slim 2026-03-06 14:11:13 +00:00
8391ef1004 Merge pull request 'commented out preflight' (#36) from fix/edit-jenkinfile into master
Reviewed-on: http://gitea.lan:3000/robbond/pleskSaas/pulls/36
2026-03-06 14:03:03 +00:00
348e26de14 commented out preflight 2026-03-06 14:02:52 +00:00
54d920bc09 Merge pull request 'build fix check for docker' (#35) from fix/jenkins-check-for-docker into master
Reviewed-on: http://gitea.lan:3000/robbond/pleskSaas/pulls/35
2026-03-06 13:58:53 +00:00
91744bf71f build fix check for docker 2026-03-06 13:58:41 +00:00
c4626e32f3 Merge pull request 'fix(ci): require docker-capable Jenkins agent with preflight checks' (#34) from feature/cl9-jenkins-docker-agent into master
Reviewed-on: http://gitea.lan:3000/robbond/pleskSaas/pulls/34
2026-03-06 13:44:20 +00:00
2 changed files with 38 additions and 37 deletions

View File

@@ -1,23 +1,23 @@
FROM cgr.dev/chainguard/node:20-dev AS deps FROM node:20-bookworm-slim AS deps
WORKDIR /app WORKDIR /app
COPY package.json package-lock.json ./ COPY package.json package-lock.json ./
RUN npm ci RUN npm ci
FROM cgr.dev/chainguard/node:20-dev AS builder FROM node:20-bookworm-slim AS builder
WORKDIR /app WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
RUN npm run build RUN npm run build
FROM cgr.dev/chainguard/node:20-dev AS prod-deps FROM node:20-bookworm-slim AS prod-deps
WORKDIR /app WORKDIR /app
COPY package.json package-lock.json ./ COPY package.json package-lock.json ./
RUN npm ci --omit=dev RUN npm ci --omit=dev
FROM cgr.dev/chainguard/node:20 AS runner FROM node:20-bookworm-slim AS runner
WORKDIR /app WORKDIR /app
ENV NODE_ENV=production ENV NODE_ENV=production

67
Jenkinsfile vendored
View File

@@ -1,7 +1,12 @@
def DEPLOY_SSH_CREDENTIAL_ID = env.DEPLOY_SSH_CREDENTIAL_ID ?: 'plesk-agency-deploy-key'
def APP_HOST = env.APP_HOST ?: '192.168.68.89'
def APP_USER = env.APP_USER ?: 'deploy'
def DEPLOY_PATH = env.DEPLOY_PATH ?: '/opt/plesk-agency-portal'
pipeline { pipeline {
// Build + deploy stages require Docker CLI/daemon access on the Jenkins node. // Build + deploy stages require Docker CLI/daemon access on the Jenkins node.
// Ensure this label maps to an agent with Docker installed and usable. // Ensure this label maps to an agent with Docker installed and usable.
agent { label 'docker' } agent any
environment { environment {
REGISTRY_IMAGE = "plesk-agency-portal" REGISTRY_IMAGE = "plesk-agency-portal"
@@ -10,24 +15,24 @@ pipeline {
} }
stages { stages {
stage('Preflight') { // stage('Preflight') {
steps { // steps {
sh ''' // sh '''
set -euo pipefail // set -euo pipefail
if ! command -v docker >/dev/null 2>&1; then // if ! command -v docker >/dev/null 2>&1; then
echo "Docker CLI is not available on this Jenkins agent." // echo "Docker CLI is not available on this Jenkins agent."
echo "Run this pipeline on a Docker-capable node (label: docker) or install Docker on the current agent." // echo "Run this pipeline on a Docker-capable node or install Docker on the current agent."
exit 1 // exit 1
fi // fi
if ! docker version >/dev/null 2>&1; then // if ! docker version >/dev/null 2>&1; then
echo "Docker is installed but not usable by Jenkins (daemon/socket/permissions issue)." // echo "Docker is installed but not usable by Jenkins (daemon/socket/permissions issue)."
exit 1 // exit 1
fi // fi
''' // '''
} // }
} // }
stage('Checkout') { stage('Checkout') {
steps { steps {
@@ -68,30 +73,26 @@ pipeline {
stage('Deploy') { stage('Deploy') {
steps { steps {
script { withCredentials([sshUserPrivateKey(
if (!env.DEPLOY_SSH_CREDENTIAL_ID) { credentialsId: DEPLOY_SSH_CREDENTIAL_ID,
error 'DEPLOY_SSH_CREDENTIAL_ID is required' keyFileVariable: 'SSH_KEY'
} )]) {
}
sshagent(credentials: ["${env.DEPLOY_SSH_CREDENTIAL_ID}"]) {
sh ''' sh '''
set -euo pipefail set -euo pipefail
: "${DEPLOY_SSH_HOST:?Missing DEPLOY_SSH_HOST}"
: "${DEPLOY_SSH_USER:?Missing DEPLOY_SSH_USER}"
: "${DEPLOY_PATH:?Missing DEPLOY_PATH}"
rsync -az \ rsync -az \
docker-compose.prod.yml \ docker-compose.prod.yml \
scripts/deploy-prod.sh \ scripts/ \
scripts/smoke-check.sh \ -e "ssh -i $SSH_KEY" \
scripts/rollback-prod.sh \ $APP_USER@$APP_HOST:$DEPLOY_PATH/
${DEPLOY_SSH_USER}@${DEPLOY_SSH_HOST}:${DEPLOY_PATH}/
docker save ${IMAGE_LATEST} ${IMAGE_BUILD} \ docker save ${IMAGE_LATEST} ${IMAGE_BUILD} \
| ssh ${DEPLOY_SSH_USER}@${DEPLOY_SSH_HOST} 'docker load' | ssh -i $SSH_KEY $APP_USER@$APP_HOST 'docker load'
ssh ${DEPLOY_SSH_USER}@${DEPLOY_SSH_HOST} \ ssh -i $SSH_KEY $APP_USER@$APP_HOST \
"chmod +x ${DEPLOY_PATH}/deploy-prod.sh ${DEPLOY_PATH}/smoke-check.sh ${DEPLOY_PATH}/rollback-prod.sh && APP_IMAGE='${IMAGE_BUILD}' DEPLOY_PATH='${DEPLOY_PATH}' ${DEPLOY_PATH}/deploy-prod.sh" "cd $DEPLOY_PATH && chmod +x ./scripts/deploy-prod.sh ./scripts/smoke-check.sh ./scripts/rollback-prod.sh"
ssh -i $SSH_KEY $APP_USER@$APP_HOST "cd $DEPLOY_PATH && ./scripts/deploy-prod.sh"
''' '''
} }
} }