Voltamos a estaca zero
Estou observando que estou alterando o código e não está resolvendo
No servidor está gerando estas três pastas
docker-compose.yml
version: '3.1'
services:
agenda:
build: .
container_name: agenda
restart: unless-stopped
ports:
- '4306:80'
external_links:
- db:db
networks:
- db-net
networks:
db-net:
external:
name: db-net
docker.sh
#!/bin/sh
cd /var/opt/netsig/agenda/
CONTAINER_NAME="agenda"
OLD="$(docker ps --all --quiet --filter=name="$CONTAINER_NAME")"
if [ -n "$OLD" ]; then
docker stop $OLD && docker rm -f $OLD
fi
Dockerfile
FROM nginx:1.17.8-alpine
COPY /dist/* /usr/share/nginx/html/
RUN ls /usr/share/nginx/html
EXPOSE 4306
CMD ["nginx", "-g", "daemon off;"]
Jenkinsfile
node("master") {
try {
stage('SCM') {
gitlabCommitStatus("SCM") {
git branch: 'master',
credentialsId: 'jenkins-gitlab',
url: "git@${env.GITLAB_URL}:guilherme/agendaangular.git"
}
}
stage('TESTE'){
gitlabCommitStatus("TESTE") {
sh 'echo TESTE'
}
}
stage ('BUILD') {
script {
if (env.gitlabBranch == 'master') {
gitlabCommitStatus("BUILD") {
sh 'npm install --force && ng build --prod --c=hom --base-href="/agenda/"'
}
} else {
updateGitlabCommitStatus name: 'BUILD', state: 'canceled'
}
}
}
stage ('DEPLOY') {
script {
sh "echo BRANCH - ${env.gitlabBranch}"
if (env.gitlabBranch == 'master') {
gitlabCommitStatus("DEPLOY") {
sh "ssh ${PRODUCTION_USER_SSH}@${PRODUCTION_SERVER} mkdir -p /var/opt/netsig/agenda/"
sh "ssh ${PRODUCTION_USER_SSH}@${PRODUCTION_SERVER} rm -rf /var/opt/netsig/agenda/*"
sh "scp -rp ./dist ${PRODUCTION_USER_SSH}@${PRODUCTION_SERVER}:${PATH_DEPLOY}/agenda/"
sh "scp -p ./Dockerfile ${PRODUCTION_USER_SSH}@${PRODUCTION_SERVER}:${PATH_DEPLOY}/agenda/"
sh "scp -p ./docker-compose.yml ${PRODUCTION_USER_SSH}@${PRODUCTION_SERVER}:${PATH_DEPLOY}/agenda/"
sh "scp -p ./docker.sh ${PRODUCTION_USER_SSH}@${PRODUCTION_SERVER}:${PATH_DEPLOY}/agenda/"
sh '''
ssh ${PRODUCTION_USER_SSH}@${PRODUCTION_SERVER} "
cd /var/opt/netsig/agenda/ &&
chmod +x docker.sh &&
sh docker.sh &&
export DOCKERHOST=$(ifconfig | grep -E '([0-9]{1,3}.){3}[0-9]{1,3}' | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d: | head -n1) &&
echo 'DOCKERHOST' $DOCKERHOST &&
docker-compose up -d --build"
'''
}
} else {
updateGitlabCommitStatus name: 'DEPLOY', state: 'canceled'
}
}
}
}catch (e) {
stage('NOTIFY FAILED')
{
updateGitlabCommitStatus name: 'pipeline', state: 'failed'
}
throw e
}
}
Entro no servidor digito este comando sudo nano /var/opt/netsig/nginx/nginx-local.conf
Incluo estas informações, mudando a porta e nome do sistema
location /agenda/ {
proxy_pass http://172.17.0.1:4306/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Request-Start $msec;
}
Envio para o GIT, e o jenkis faz tudo.
Mas este deu erro, todos os outros deram certo.
O que pode ser ?