From fdcb1ccf98259fcfb77796e3815c914edf901af3 Mon Sep 17 00:00:00 2001 From: Fernando Araoz Date: Sun, 15 Dec 2024 22:00:13 -0500 Subject: [PATCH] ci: traefik deploy --- Jenkinsfile | 49 +++++++++++++++++++++++----------------------- docker-compose.yml | 24 +++++++++++++++++++++++ 2 files changed, 48 insertions(+), 25 deletions(-) create mode 100644 docker-compose.yml diff --git a/Jenkinsfile b/Jenkinsfile index 7805589..d6c67de 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,31 +1,30 @@ pipeline { - agent any - environment { - PATH = "/var/lib/jenkins/bin:/var/lib/jenkins/.nvm/versions/node/v20.9.0/bin:${env.PATH}" - } - stages { - stage('Install deps') { - agent { + agent any + stages { + stage('Build') { + agent { docker { reuseNode true - image 'node:22' + image 'node:22-alpine' } } - steps { - sh 'npm i -g pnpm' - sh 'pnpm i' - sh 'pnpm build' - } - } - stage('Deploy') { - steps { - // Clean previous deploy - sh 'rm -rf /var/www/dev.araozu.combi/assets /var/www/dev.araozu.combi/data /var/www/dev.araozu.combi/n' - // Check if the tiles folder exists. If it does not, - // extract the tiles - sh "if [ ! -d /var/www/dev.araozu.combi/tiles ]; then \n tar -xf tiles.tar.gz -C /var/www/dev.araozu.combi \n fi" - sh 'cp -r ./dist/* /var/www/dev.araozu.combi/' - } - } - } + steps { + sh 'npm i -g pnpm' + sh 'pnpm i' + sh 'pnpm build' + } + } + stage('Deploy') { + steps { + // Clean previous deploy + sh 'rm -rf /var/www/dev.araozu.combi/assets /var/www/dev.araozu.combi/data /var/www/dev.araozu.combi/n' + // Check if the tiles folder exists. If it does not, + // extract the tiles + sh "if [ ! -d /var/www/dev.araozu.combi/tiles ]; then \n tar -xf tiles.tar.gz -C /var/www/dev.araozu.combi \n fi" + sh 'cp -r ./dist/* /var/www/dev.araozu.combi/' + sh 'docker-compose down || true' + sh 'docker-compose up -d' + } + } + } } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3c1fd1b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,24 @@ +services: + dev_araozu_combi: + image: nginx:alpine + restart: unless-stopped + container_name: dev_araozu_combi + volumes: + - /var/www/dev.araozu_combi/:/usr/share/nginx/html + labels: + - "traefik.enable=true" + - "traefik.http.routers.dev_araozu_combi.rule=Host(`combi.araozu.dev`)" + - "traefik.http.routers.dev_araozu_combi.entrypoints=websecure" + - "traefik.http.routers.dev_araozu_combi.tls=true" + - "traefik.http.routers.dev_araozu_combi.tls.certresolver=hetzner-resolver" + - "traefik.http.routers.dev_araozu_combi.tls.domains[0].main=araozu.dev" + - "traefik.http.routers.dev_araozu_combi.tls.domains[0].sans=*.araozu.dev" + networks: + - proxy + +networks: + proxy: + name: proxy + external: true + +