Compare commits
No commits in common. "e310934345875ba324f86937d571cdffb5e99cdc" and "d1e21c8da98c0d99604ba4b8db3a709c9e5373f5" have entirely different histories.
e310934345
...
d1e21c8da9
3 changed files with 2 additions and 160 deletions
158
pipeline.md
158
pipeline.md
|
|
@ -1,158 +0,0 @@
|
||||||
pipeline {
|
|
||||||
agent any
|
|
||||||
|
|
||||||
triggers {
|
|
||||||
GenericTrigger(
|
|
||||||
genericVariables: [
|
|
||||||
[key: 'action', value: '$.action'],
|
|
||||||
[key: 'merged', value: '$.pull_request.merged']
|
|
||||||
],
|
|
||||||
causeString: 'Pipeline disparado por merge de PR no Forgejo',
|
|
||||||
printContributedVariables: true,
|
|
||||||
printPostContent: true,
|
|
||||||
regexpFilterText: '$action $merged',
|
|
||||||
regexpFilterExpression: 'closed true'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
environment {
|
|
||||||
DEPLOY_USER = "jenkins"
|
|
||||||
DEPLOY_SERVER = "192.168.1.81"
|
|
||||||
IMAGE_NAME = "portal-app"
|
|
||||||
CONTAINER_NAME = "portal-app"
|
|
||||||
REMOTE_PATH = "/home/jenkins/app"
|
|
||||||
}
|
|
||||||
|
|
||||||
stages {
|
|
||||||
|
|
||||||
stage('Testar Conexão SSH') {
|
|
||||||
steps {
|
|
||||||
sshagent(credentials: ['ssh-key-jenkins']) {
|
|
||||||
sh "ssh -o StrictHostKeyChecking=no ${DEPLOY_USER}@${DEPLOY_SERVER} 'echo Conexão SSH bem-sucedida!'"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Ver chave pública usada') {
|
|
||||||
steps {
|
|
||||||
sshagent(credentials: ['ssh-key-jenkins']) {
|
|
||||||
sh 'ssh-add -L'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Checkout Código (local, só para pegar commit hash)') {
|
|
||||||
steps {
|
|
||||||
git branch: 'main', url: 'https://forgeo-olymp.duckdns.org/rayankonecny/portal-app.git' // usando IP local por confiabilidade
|
|
||||||
script {
|
|
||||||
env.GIT_COMMIT = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
|
|
||||||
env.BUILD_TAG = "${env.BUILD_NUMBER}-${env.GIT_COMMIT}"
|
|
||||||
echo "BUILD_TAG definido como: ${env.BUILD_TAG}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Clonar Projeto e Criar Dockerfile no Servidor') {
|
|
||||||
steps {
|
|
||||||
sshagent(credentials: ['ssh-key-jenkins']) {
|
|
||||||
script {
|
|
||||||
sh """
|
|
||||||
ssh -o StrictHostKeyChecking=no ${DEPLOY_USER}@${DEPLOY_SERVER} '
|
|
||||||
set -e
|
|
||||||
|
|
||||||
mkdir -p ${REMOTE_PATH}
|
|
||||||
git config --global --add safe.directory ${REMOTE_PATH}
|
|
||||||
rm -rf ${REMOTE_PATH}
|
|
||||||
|
|
||||||
git clone https://forgeo-olymp.duckdns.org/rayankonecny/portal-app.git ${REMOTE_PATH}
|
|
||||||
|
|
||||||
if [ -f ${REMOTE_PATH}/.env ]; then
|
|
||||||
echo "[INFO] Removendo NODE_ENV do .env para evitar erro com Vite"
|
|
||||||
sed -i "/NODE_ENV/d" ${REMOTE_PATH}/.env
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat <<EOF > ${REMOTE_PATH}/Dockerfile
|
|
||||||
FROM node:18-alpine
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY package*.json ./
|
|
||||||
|
|
||||||
RUN npm install
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
EXPOSE 5173
|
|
||||||
|
|
||||||
CMD ["npm", "run", "dev"]
|
|
||||||
EOF
|
|
||||||
'
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Build da Imagem Podman') {
|
|
||||||
steps {
|
|
||||||
sshagent(credentials: ['ssh-key-jenkins']) {
|
|
||||||
sh """
|
|
||||||
ssh -o StrictHostKeyChecking=no ${DEPLOY_USER}@${DEPLOY_SERVER} '
|
|
||||||
cd ${REMOTE_PATH} &&
|
|
||||||
podman build -t ${IMAGE_NAME}:${BUILD_TAG} -t ${IMAGE_NAME}:latest .
|
|
||||||
'
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Parar e Remover Container Antigo') {
|
|
||||||
steps {
|
|
||||||
sshagent(credentials: ['ssh-key-jenkins']) {
|
|
||||||
sh """
|
|
||||||
ssh ${DEPLOY_USER}@${DEPLOY_SERVER} '
|
|
||||||
podman stop ${CONTAINER_NAME} || true &&
|
|
||||||
podman rm ${CONTAINER_NAME} || true
|
|
||||||
'
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Deploy no Servidor') {
|
|
||||||
steps {
|
|
||||||
sshagent(credentials: ['ssh-key-jenkins']) {
|
|
||||||
sh """
|
|
||||||
ssh ${DEPLOY_USER}@${DEPLOY_SERVER} '
|
|
||||||
podman run -d --network host --name ${CONTAINER_NAME} ${IMAGE_NAME}:${BUILD_TAG}
|
|
||||||
'
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Verificar Status do Container') {
|
|
||||||
steps {
|
|
||||||
sshagent(credentials: ['ssh-key-jenkins']) {
|
|
||||||
sh """
|
|
||||||
ssh ${DEPLOY_USER}@${DEPLOY_SERVER} '
|
|
||||||
podman ps | grep ${CONTAINER_NAME} || echo "Container não encontrado"
|
|
||||||
'
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Limpeza de Imagens Antigas') {
|
|
||||||
steps {
|
|
||||||
sshagent(credentials: ['ssh-key-jenkins']) {
|
|
||||||
sh """
|
|
||||||
ssh ${DEPLOY_USER}@${DEPLOY_SERVER} '
|
|
||||||
podman image prune -f
|
|
||||||
'
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -3,7 +3,7 @@ import * as React from 'react'
|
||||||
const App: React.FC = () => {
|
const App: React.FC = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h1>Testando</h1>
|
<h1>Hello</h1>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
|
||||||
color-scheme: light dark;
|
color-scheme: light dark;
|
||||||
color: rgba(188, 82, 197, 0.87);
|
color: rgba(255, 255, 255, 0.87);
|
||||||
background-color: #242424;
|
background-color: #242424;
|
||||||
|
|
||||||
font-synthesis: none;
|
font-synthesis: none;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue