From 73ceb3bbdd792f17e8e9907bc2019e96f0a99a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 16 Oct 2025 14:14:51 -0300 Subject: [PATCH 01/45] =?UTF-8?q?Se=20agrega=20nuevo=20action=20para=20rea?= =?UTF-8?q?lizar=20pack=20de=20documentaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-pack-image.yml | 50 ++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/build-pack-image.yml diff --git a/.github/workflows/build-pack-image.yml b/.github/workflows/build-pack-image.yml new file mode 100644 index 00000000..e5941b05 --- /dev/null +++ b/.github/workflows/build-pack-image.yml @@ -0,0 +1,50 @@ +name: Deploy blog + +on: + push: + branches: + - feature/* + +jobs: + build-and-package: + runs-on: ubuntu-latest + + env: + BRANCH_NAME: ${{ github.ref_name }} + PACKAGE_NAME: docs-sp-${{ github.ref_name }}.tar.gz + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.1.1 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + cache: pnpm + + - name: Install Deps + run: pnpm install --no-frozen-lockfile + + - name: Build Blog + env: + NODE_OPTIONS: --max_old_space_size=8192 + run: pnpm run build:webpack + + - name: Compress Build Output (tar.gz) + run: tar -czvf $PACKAGE_NAME -C dist . + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BRANCH_NAME }}-package + path: ${{ env.PACKAGE_NAME }} + From bda9934d6811a364a630ab67601fec718438ac30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 16 Oct 2025 14:18:39 -0300 Subject: [PATCH 02/45] Fix action --- .../workflows/{build-pack-image.yml => build-and-package.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{build-pack-image.yml => build-and-package.yml} (96%) diff --git a/.github/workflows/build-pack-image.yml b/.github/workflows/build-and-package.yml similarity index 96% rename from .github/workflows/build-pack-image.yml rename to .github/workflows/build-and-package.yml index e5941b05..6569f47e 100644 --- a/.github/workflows/build-pack-image.yml +++ b/.github/workflows/build-and-package.yml @@ -43,7 +43,7 @@ jobs: run: tar -czvf $PACKAGE_NAME -C dist . - name: Upload Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.BRANCH_NAME }}-package path: ${{ env.PACKAGE_NAME }} From e32d015b7875e3a7cbb01474103065208e12d232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 16 Oct 2025 14:31:19 -0300 Subject: [PATCH 03/45] Fix action --- .github/workflows/build-and-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 6569f47e..bde06c38 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -47,4 +47,4 @@ jobs: with: name: ${{ env.BRANCH_NAME }}-package path: ${{ env.PACKAGE_NAME }} - + From e975067994480b928c6a543e92198197c1a616fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 16 Oct 2025 14:33:58 -0300 Subject: [PATCH 04/45] Fix action --- .github/workflows/build-and-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index bde06c38..909bdc78 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -3,7 +3,7 @@ name: Deploy blog on: push: branches: - - feature/* + - feature* jobs: build-and-package: From fc61f828c64a2c221367e572c108c2ff1a427d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 16 Oct 2025 14:57:29 -0300 Subject: [PATCH 05/45] Fix action --- .github/workflows/build-and-package.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 909bdc78..cb5d2b96 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -47,4 +47,6 @@ jobs: with: name: ${{ env.BRANCH_NAME }}-package path: ${{ env.PACKAGE_NAME }} + overwrite: true + compression-level: 0 From 04a1770cb03a66217f673e3f9e7581f15ca8b63c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 16 Oct 2025 15:08:42 -0300 Subject: [PATCH 06/45] Fix action --- .github/workflows/build-and-package.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index cb5d2b96..e33c1151 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -39,14 +39,10 @@ jobs: NODE_OPTIONS: --max_old_space_size=8192 run: pnpm run build:webpack - - name: Compress Build Output (tar.gz) - run: tar -czvf $PACKAGE_NAME -C dist . - - name: Upload Artifact uses: actions/upload-artifact@v4 with: name: ${{ env.BRANCH_NAME }}-package - path: ${{ env.PACKAGE_NAME }} + path: dist overwrite: true - compression-level: 0 From 3c9fa411b79e3891a3a6ba0c320e4398f2a533be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 16 Oct 2025 16:58:01 -0300 Subject: [PATCH 07/45] Set to store in DigitalOcean --- .github/workflows/build-and-package.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index e33c1151..1497b34f 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -39,10 +39,16 @@ jobs: NODE_OPTIONS: --max_old_space_size=8192 run: pnpm run build:webpack - - name: Upload Artifact - uses: actions/upload-artifact@v4 + - name: Compress Build Output (tar.gz) + run: tar -czvf $PACKAGE_NAME -C dist . + + - name: Upload site pack to S3 + uses: BetaHuhn/do-spaces-action@v2 with: - name: ${{ env.BRANCH_NAME }}-package - path: dist - overwrite: true + access_key: ${{ vars.AWS_ACCESS_KEY_ID}} + secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + space_name: 'docs-sp' + space_region: 'nyc3' + source: $PACKAGE_NAME + out_dir: 'html/' From 12e757aa54e34e98833388bc671bf884e6f1cc8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 16 Oct 2025 17:03:53 -0300 Subject: [PATCH 08/45] Fix action --- .github/workflows/build-and-package.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 1497b34f..44041e4a 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -42,6 +42,9 @@ jobs: - name: Compress Build Output (tar.gz) run: tar -czvf $PACKAGE_NAME -C dist . + - name: Listar archivos en el directorio de trabajo + run: ls -al + - name: Upload site pack to S3 uses: BetaHuhn/do-spaces-action@v2 with: From 5c49e6bd2a94347500991ee01d8217bf0c36cdaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 16 Oct 2025 17:06:16 -0300 Subject: [PATCH 09/45] Fix Action --- .github/workflows/build-and-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 44041e4a..3a84a1f1 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -52,6 +52,6 @@ jobs: secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} space_name: 'docs-sp' space_region: 'nyc3' - source: $PACKAGE_NAME + source: ${{ env.PACKAGE_NAME }} out_dir: 'html/' From c611f96bba992e3e5ab14c5d6b9cf7977deda9b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 16 Oct 2025 17:07:48 -0300 Subject: [PATCH 10/45] Fix Action --- .github/workflows/build-and-package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 3a84a1f1..d8cab7d8 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -54,4 +54,5 @@ jobs: space_region: 'nyc3' source: ${{ env.PACKAGE_NAME }} out_dir: 'html/' + overwrite: true From 1a894c0c6e3b134f4dd3a4a0303f62c9b7eab7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 16 Oct 2025 17:08:48 -0300 Subject: [PATCH 11/45] Fix action --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e5d9de57..80fa8daa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,8 @@ name: Test blog -on: - push: - pull_request: +#on: +# push: +# pull_request: jobs: build-test: From ddcf527199193d70e17315b519bca673845773d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 16 Oct 2025 17:12:42 -0300 Subject: [PATCH 12/45] Test override --- .github/workflows/build-and-package.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index d8cab7d8..b9d465dc 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -42,9 +42,6 @@ jobs: - name: Compress Build Output (tar.gz) run: tar -czvf $PACKAGE_NAME -C dist . - - name: Listar archivos en el directorio de trabajo - run: ls -al - - name: Upload site pack to S3 uses: BetaHuhn/do-spaces-action@v2 with: From 4a592424d8d6abe954e6bc5c43dd7ccda6402772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 16 Oct 2025 21:15:06 -0300 Subject: [PATCH 13/45] Se agrega Docker Repo DitgitalOcean --- .github/workflows/build-and-package.yml | 73 +++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index b9d465dc..df65035c 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -53,3 +53,76 @@ jobs: out_dir: 'html/' overwrite: true + check-digitalocean-secrets: + name: Check if Digitalocean registry information was set on secrets + needs: + - build-and-package + runs-on: ubuntu-latest + outputs: + is_have_secrets: ${{ steps.check_digitalocean_secrets_job.outputs.is_have_secrets }} + steps: + - id: check_digitalocean_secrets_job + run: | + if [[ "${{ vars.DIGITALOCEAN_REGISTRY }}" != "" && \ + "${{ vars.DOCKER_REPO_DOCS_SP }}" != "" && \ + "${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}" != "" ]]; \ + then + echo "Secrets to use DigitalOcean container registry are configured in the repo" + echo "is_have_secrets=true" >> $GITHUB_OUTPUT + else + echo "Secrets to use DigitalOcean container registry were not configured in the repo" + echo "is_have_secrets=false" >> $GITHUB_OUTPUT + fi + + build-nginx-image: + name: Build and Push Nginx Image + runs-on: ubuntu-latest + needs: + - check-digitalocean-secrets + if: needs.check-digitalocean-secrets.outputs.is_have_secrets == 'true' + steps: + + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Configure AWS Credentials for S3 Access + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ vars.AWS_ACCESS_KEY_ID}} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Download all tar.gz files from S3/Spaces + run: | + aws configure set default.s3.endpoint_url https://nyc3.digitaloceanspaces.com + mkdir -p s3-downloads + aws s3 sync s3://docs-sp/html/ s3-downloads/ --recursive + env: + DO_SPACE_REGION: nyc3 + + - name: show-directory + cmd: ls -alh s3-downloads + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub (o tu registro preferido) + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + # ------------------------------------------- + # 3. Construir la imagen con los tar.gz dentro + # ------------------------------------------- + - name: Build and push Nginx image + uses: docker/build-push-action@v5 + with: + # El contexto es la raíz del repositorio donde se descargó 's3-downloads' + context: . + # Indica que se haga push después de construir + push: true + # Etiqueta de la imagen (ej: myuser/myrepo:latest) + tags: tu_usuario/tu_repo:nginx-deploy + # El Dockerfile que vamos a crear + file: ./Dockerfile From 8489f28aa07b255b41a8945337a034e0be40de2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 16 Oct 2025 21:18:25 -0300 Subject: [PATCH 14/45] Fix action --- .github/workflows/build-and-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index df65035c..71b088b9 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -101,7 +101,7 @@ jobs: DO_SPACE_REGION: nyc3 - name: show-directory - cmd: ls -alh s3-downloads + run: ls -alh s3-downloads - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 From e37ccd3b2f3847059d59aedcda0b175859d990a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 30 Oct 2025 17:45:20 -0300 Subject: [PATCH 15/45] =?UTF-8?q?Correcci=C3=B3n=20de=20login=20en=20s3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-and-package.yml | 27 +++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 71b088b9..2c533c38 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -85,12 +85,27 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Configure AWS Credentials for S3 Access - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ vars.AWS_ACCESS_KEY_ID}} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-east-1 + - name: Install AWS CLI + uses: aws-actions/setup-aws-cli@v4 + + - name: Configure and Download from DigitalOcean Spaces + run: | + # 1. Configurar las credenciales y el endpoint de DigitalOcean + # La clave secreta y el ID se toman de los secretos/variables de GitHub + aws configure set aws_access_key_id ${{ vars.AWS_ACCESS_KEY_ID }} + aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + # ¡Paso crucial! Configurar el endpoint para apuntar a la región de DO + aws configure set default.s3.endpoint_url https://${{ env.DO_SPACE_REGION }}.digitaloceanspaces.com + + # 2. Crear una carpeta local para guardar los archivos + mkdir -p s3-downloads + + # 3. Sincronizar (Descargar) el contenido del Space (Bucket) al directorio local + # El nombre del Space es 'docs-sp' y la carpeta es 'html/' + aws s3 sync s3://docs-sp/html/ s3-downloads/ --recursive + env: + DO_SPACE_REGION: nyc3 - name: Download all tar.gz files from S3/Spaces run: | From cf9e5225a0dfa4127197509be2cfec4b5b2db7a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 30 Oct 2025 18:06:26 -0300 Subject: [PATCH 16/45] Fix Action --- .github/workflows/build-and-package.yml | 108 +++++++++++------------- 1 file changed, 47 insertions(+), 61 deletions(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 2c533c38..2a7573e9 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -6,52 +6,52 @@ on: - feature* jobs: - build-and-package: - runs-on: ubuntu-latest - - env: - BRANCH_NAME: ${{ github.ref_name }} - PACKAGE_NAME: docs-sp-${{ github.ref_name }}.tar.gz - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: true - fetch-depth: 0 - - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: 9.1.1 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 20 - cache: pnpm - - - name: Install Deps - run: pnpm install --no-frozen-lockfile - - - name: Build Blog - env: - NODE_OPTIONS: --max_old_space_size=8192 - run: pnpm run build:webpack - - - name: Compress Build Output (tar.gz) - run: tar -czvf $PACKAGE_NAME -C dist . - - - name: Upload site pack to S3 - uses: BetaHuhn/do-spaces-action@v2 - with: - access_key: ${{ vars.AWS_ACCESS_KEY_ID}} - secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - space_name: 'docs-sp' - space_region: 'nyc3' - source: ${{ env.PACKAGE_NAME }} - out_dir: 'html/' - overwrite: true + #build-and-package: + # runs-on: ubuntu-latest + + # env: + # BRANCH_NAME: ${{ github.ref_name }} + # PACKAGE_NAME: docs-sp-${{ github.ref_name }}.tar.gz + # + # steps: + # - name: Checkout + # uses: actions/checkout@v3 + # with: + # submodules: true + # fetch-depth: 0 + + # - name: Install pnpm + # uses: pnpm/action-setup@v4 + # with: + # version: 9.1.1 + + # - name: Setup Node.js + # uses: actions/setup-node@v3 + # with: + # node-version: 20 + # cache: pnpm + + # - name: Install Deps + # run: pnpm install --no-frozen-lockfile + + # - name: Build Blog + # env: + # NODE_OPTIONS: --max_old_space_size=8192 + # run: pnpm run build:webpack + + # - name: Compress Build Output (tar.gz) + # run: tar -czvf $PACKAGE_NAME -C dist . + + # - name: Upload site pack to S3 + # uses: BetaHuhn/do-spaces-action@v2 + # with: + # access_key: ${{ vars.AWS_ACCESS_KEY_ID}} + # secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + # space_name: 'docs-sp' + # space_region: 'nyc3' + # source: ${{ env.PACKAGE_NAME }} + # out_dir: 'html/' + # overwrite: true check-digitalocean-secrets: name: Check if Digitalocean registry information was set on secrets @@ -86,34 +86,20 @@ jobs: uses: actions/checkout@v4 - name: Install AWS CLI - uses: aws-actions/setup-aws-cli@v4 + uses: aws-actions/aws-cli-install@v2 - name: Configure and Download from DigitalOcean Spaces run: | - # 1. Configurar las credenciales y el endpoint de DigitalOcean - # La clave secreta y el ID se toman de los secretos/variables de GitHub aws configure set aws_access_key_id ${{ vars.AWS_ACCESS_KEY_ID }} aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} - # ¡Paso crucial! Configurar el endpoint para apuntar a la región de DO aws configure set default.s3.endpoint_url https://${{ env.DO_SPACE_REGION }}.digitaloceanspaces.com - # 2. Crear una carpeta local para guardar los archivos mkdir -p s3-downloads - # 3. Sincronizar (Descargar) el contenido del Space (Bucket) al directorio local - # El nombre del Space es 'docs-sp' y la carpeta es 'html/' aws s3 sync s3://docs-sp/html/ s3-downloads/ --recursive env: DO_SPACE_REGION: nyc3 - - - name: Download all tar.gz files from S3/Spaces - run: | - aws configure set default.s3.endpoint_url https://nyc3.digitaloceanspaces.com - mkdir -p s3-downloads - aws s3 sync s3://docs-sp/html/ s3-downloads/ --recursive - env: - DO_SPACE_REGION: nyc3 - name: show-directory run: ls -alh s3-downloads From 6c35476c00d0d09e926e027326b6cb492c715983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 30 Oct 2025 18:07:37 -0300 Subject: [PATCH 17/45] Fix Action --- .github/workflows/build-and-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 2a7573e9..03ad819f 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -55,8 +55,8 @@ jobs: check-digitalocean-secrets: name: Check if Digitalocean registry information was set on secrets - needs: - - build-and-package + #needs: + # - build-and-package runs-on: ubuntu-latest outputs: is_have_secrets: ${{ steps.check_digitalocean_secrets_job.outputs.is_have_secrets }} From 42ed2aa184e7e01b036e4ed52d9f9dba684e83ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 6 Nov 2025 13:01:03 -0300 Subject: [PATCH 18/45] Fix Action --- .github/workflows/build-and-package.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 03ad819f..39d2573d 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -90,15 +90,16 @@ jobs: - name: Configure and Download from DigitalOcean Spaces run: | - aws configure set aws_access_key_id ${{ vars.AWS_ACCESS_KEY_ID }} - aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} - - aws configure set default.s3.endpoint_url https://${{ env.DO_SPACE_REGION }}.digitaloceanspaces.com - mkdir -p s3-downloads - - aws s3 sync s3://docs-sp/html/ s3-downloads/ --recursive + + # Descargar todos los paquetes comprimidos desde DigitalOcean Spaces + aws s3 sync s3://docs-sp/html/ s3-downloads/ \ + --endpoint-url https://${{ env.DO_SPACE_REGION }}.digitaloceanspaces.com \ + --recursive env: + AWS_ACCESS_KEY_ID: ${{ vars.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-east-1 DO_SPACE_REGION: nyc3 - name: show-directory From c24988517a9b69e78bbbcc2ea314a1b729040134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 6 Nov 2025 13:53:10 -0300 Subject: [PATCH 19/45] Fix Action --- .github/workflows/download-s3-files.yml | 53 +++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/download-s3-files.yml diff --git a/.github/workflows/download-s3-files.yml b/.github/workflows/download-s3-files.yml new file mode 100644 index 00000000..68f1e32d --- /dev/null +++ b/.github/workflows/download-s3-files.yml @@ -0,0 +1,53 @@ +name: Download S3 Files + +on: + push: + branches: + - '**' # Se ejecuta en cualquier rama + +jobs: + download-from-s3: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Configure AWS CLI for DigitalOcean Spaces + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ vars.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 # Región requerida por AWS CLI, aunque no se usa con DO Spaces + + - name: Create download directory + run: mkdir -p downloaded-files + + - name: Download files from DigitalOcean Spaces + env: + AWS_ACCESS_KEY_ID: ${{ vars.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + run: | + echo "Descargando archivos de docs-sp/html..." + aws s3 sync \ + s3://docs-sp/html/ \ + downloaded-files/ \ + --endpoint-url https://nyc3.digitaloceanspaces.com \ + --no-progress + + - name: List downloaded files + run: | + echo "==========================================" + echo "Archivos descargados:" + echo "==========================================" + ls -lh downloaded-files/ + echo "" + echo "==========================================" + echo "Archivos .tar.gz encontrados:" + echo "==========================================" + find downloaded-files/ -name "*.tar.gz" -type f -exec ls -lh {} \; + echo "" + echo "==========================================" + echo "Total de archivos descargados:" + echo "==========================================" + find downloaded-files/ -type f | wc -l From b99f8867026b4d84d56c1b231a922620b6207ea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 6 Nov 2025 14:21:39 -0300 Subject: [PATCH 20/45] Fix Action --- .github/workflows/download-s3-files.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/download-s3-files.yml b/.github/workflows/download-s3-files.yml index 68f1e32d..c084d7ea 100644 --- a/.github/workflows/download-s3-files.yml +++ b/.github/workflows/download-s3-files.yml @@ -13,13 +13,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Configure AWS CLI for DigitalOcean Spaces - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ vars.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-east-1 # Región requerida por AWS CLI, aunque no se usa con DO Spaces - - name: Create download directory run: mkdir -p downloaded-files From ecc171149bc64f0d64f83b79349719404be88af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 6 Nov 2025 15:10:08 -0300 Subject: [PATCH 21/45] Fix Action --- .github/workflows/build-and-package.yml | 118 ++++++++++++------------ 1 file changed, 58 insertions(+), 60 deletions(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 39d2573d..b37f9605 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -6,57 +6,57 @@ on: - feature* jobs: - #build-and-package: - # runs-on: ubuntu-latest - - # env: - # BRANCH_NAME: ${{ github.ref_name }} - # PACKAGE_NAME: docs-sp-${{ github.ref_name }}.tar.gz - # - # steps: - # - name: Checkout - # uses: actions/checkout@v3 - # with: - # submodules: true - # fetch-depth: 0 - - # - name: Install pnpm - # uses: pnpm/action-setup@v4 - # with: - # version: 9.1.1 - - # - name: Setup Node.js - # uses: actions/setup-node@v3 - # with: - # node-version: 20 - # cache: pnpm - - # - name: Install Deps - # run: pnpm install --no-frozen-lockfile - - # - name: Build Blog - # env: - # NODE_OPTIONS: --max_old_space_size=8192 - # run: pnpm run build:webpack - - # - name: Compress Build Output (tar.gz) - # run: tar -czvf $PACKAGE_NAME -C dist . - - # - name: Upload site pack to S3 - # uses: BetaHuhn/do-spaces-action@v2 - # with: - # access_key: ${{ vars.AWS_ACCESS_KEY_ID}} - # secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - # space_name: 'docs-sp' - # space_region: 'nyc3' - # source: ${{ env.PACKAGE_NAME }} - # out_dir: 'html/' - # overwrite: true + build-and-package: + runs-on: ubuntu-latest + + env: + BRANCH_NAME: ${{ github.ref_name }} + PACKAGE_NAME: docs-sp-${{ github.ref_name }}.tar.gz + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.1.1 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + cache: pnpm + + - name: Install Deps + run: pnpm install --no-frozen-lockfile + + - name: Build Blog + env: + NODE_OPTIONS: --max_old_space_size=8192 + run: pnpm run build:webpack + + - name: Compress Build Output (tar.gz) + run: tar -czvf $PACKAGE_NAME -C dist . + + - name: Upload site pack to S3 + uses: BetaHuhn/do-spaces-action@v2 + with: + access_key: ${{ vars.AWS_ACCESS_KEY_ID}} + secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + space_name: 'docs-sp' + space_region: 'nyc3' + source: ${{ env.PACKAGE_NAME }} + out_dir: 'html/' + overwrite: true check-digitalocean-secrets: name: Check if Digitalocean registry information was set on secrets - #needs: - # - build-and-package + needs: + - build-and-package runs-on: ubuntu-latest outputs: is_have_secrets: ${{ steps.check_digitalocean_secrets_job.outputs.is_have_secrets }} @@ -85,22 +85,20 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Install AWS CLI - uses: aws-actions/aws-cli-install@v2 - - - name: Configure and Download from DigitalOcean Spaces - run: | - mkdir -p s3-downloads + - name: Create download directory + run: mkdir -p s3-downloads - # Descargar todos los paquetes comprimidos desde DigitalOcean Spaces - aws s3 sync s3://docs-sp/html/ s3-downloads/ \ - --endpoint-url https://${{ env.DO_SPACE_REGION }}.digitaloceanspaces.com \ - --recursive + - name: Download from DigitalOcean Spaces env: AWS_ACCESS_KEY_ID: ${{ vars.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-1 - DO_SPACE_REGION: nyc3 + run: | + echo "Descargando archivos de docs-sp/html..." + aws s3 sync \ + s3://docs-sp/html/ \ + s3-downloads/ \ + --endpoint-url https://nyc3.digitaloceanspaces.com \ + --no-progress - name: show-directory run: ls -alh s3-downloads From 6f4c71aa5c81cc3f1e51b697ec55280b5e0787c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 6 Nov 2025 16:58:03 -0300 Subject: [PATCH 22/45] Fix Action --- .github/workflows/build-and-package.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index b37f9605..7a20bfaf 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -106,23 +106,16 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Log in to Docker Hub (o tu registro preferido) + - name: Log in to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - # ------------------------------------------- - # 3. Construir la imagen con los tar.gz dentro - # ------------------------------------------- + - name: Build and push Nginx image uses: docker/build-push-action@v5 with: - # El contexto es la raíz del repositorio donde se descargó 's3-downloads' - context: . - # Indica que se haga push después de construir + context: . push: true - # Etiqueta de la imagen (ej: myuser/myrepo:latest) tags: tu_usuario/tu_repo:nginx-deploy - # El Dockerfile que vamos a crear file: ./Dockerfile From 7f6efe1c31672a65bbc923e6b9e76b6745661f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 6 Nov 2025 17:03:04 -0300 Subject: [PATCH 23/45] Fix Action --- .github/workflows/build-and-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 7a20bfaf..a3321631 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -117,5 +117,5 @@ jobs: with: context: . push: true - tags: tu_usuario/tu_repo:nginx-deploy + tags: registry.digitalocean.com/spuy/docs-md:main file: ./Dockerfile From d44dc789600a1b54c56c4ad2fd89ded60b4e32cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 6 Nov 2025 17:15:03 -0300 Subject: [PATCH 24/45] Fix Action --- .github/workflows/build-and-package.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index a3321631..5be187c3 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -106,16 +106,17 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Log in to Docker Hub + - name: Log in to DigitalOcean Container Registry uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + registry: registry.digitalocean.com + username: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + password: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} - name: Build and push Nginx image uses: docker/build-push-action@v5 with: context: . push: true - tags: registry.digitalocean.com/spuy/docs-md:main + tags: ${{ vars.DIGITALOCEAN_REGISTRY }}/${{ vars.DOCKER_REPO_DOCS_SP }}:main file: ./Dockerfile From dbf4c039ed97af43563c7f0f0e35c384d627db54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 6 Nov 2025 17:23:42 -0300 Subject: [PATCH 25/45] Fix Action --- Dockerfile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..dc15468d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# Usar la última versión estable de nginx +FROM nginx:stable + +# Crear directorio temporal para los archivos comprimidos +WORKDIR /tmp + +# Copiar todos los archivos tar.gz descargados de S3 +COPY s3-downloads/*.tar.gz /tmp/ + +# Descomprimir todos los archivos tar.gz en el directorio de nginx +# El directorio por defecto de nginx es /usr/share/nginx/html +RUN for file in /tmp/*.tar.gz; do \ + if [ -f "$file" ]; then \ + echo "Descomprimiendo $file..."; \ + tar -xzf "$file" -C /usr/share/nginx/html/; \ + fi \ + done && \ + # Limpiar los archivos comprimidos para reducir el tamaño de la imagen + rm -f /tmp/*.tar.gz + +# Exponer el puerto 80 +EXPOSE 80 + +# El comando por defecto de nginx ya está definido en la imagen base +# nginx -g "daemon off;" From a7d7cf751f77e5a9e320657b4d82f0a09f71bff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 6 Nov 2025 17:45:47 -0300 Subject: [PATCH 26/45] Fix Action --- Dockerfile | 10 +++++++--- docker-compose.yml | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index dc15468d..bd806660 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,12 +7,16 @@ WORKDIR /tmp # Copiar todos los archivos tar.gz descargados de S3 COPY s3-downloads/*.tar.gz /tmp/ -# Descomprimir todos los archivos tar.gz en el directorio de nginx +# Descomprimir cada archivo tar.gz en su propio directorio dentro de nginx # El directorio por defecto de nginx es /usr/share/nginx/html RUN for file in /tmp/*.tar.gz; do \ if [ -f "$file" ]; then \ - echo "Descomprimiendo $file..."; \ - tar -xzf "$file" -C /usr/share/nginx/html/; \ + # Obtener el nombre base sin la extensión .tar.gz + dirname=$(basename "$file" .tar.gz); \ + echo "Descomprimiendo $file en directorio $dirname..."; \ + # Crear directorio específico y descomprimir + mkdir -p /usr/share/nginx/html/$dirname; \ + tar -xzf "$file" -C /usr/share/nginx/html/$dirname/; \ fi \ done && \ # Limpiar los archivos comprimidos para reducir el tamaño de la imagen diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..d9d86d92 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3.8' + +services: + docs-sp-nginx: + image: registry.digitalocean.com/spuy/docs-sp:main + container_name: docs-sp-nginx + ports: + - "8081:80" + restart: unless-stopped + environment: + - TZ=America/Montevideo + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:80"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 10s From 037801e2cf7961196ec7d08188e56b58d6f07b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 6 Nov 2025 17:46:30 -0300 Subject: [PATCH 27/45] Fix Action --- .github/workflows/download-s3-files.yml | 46 ------------------------- 1 file changed, 46 deletions(-) delete mode 100644 .github/workflows/download-s3-files.yml diff --git a/.github/workflows/download-s3-files.yml b/.github/workflows/download-s3-files.yml deleted file mode 100644 index c084d7ea..00000000 --- a/.github/workflows/download-s3-files.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Download S3 Files - -on: - push: - branches: - - '**' # Se ejecuta en cualquier rama - -jobs: - download-from-s3: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Create download directory - run: mkdir -p downloaded-files - - - name: Download files from DigitalOcean Spaces - env: - AWS_ACCESS_KEY_ID: ${{ vars.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - run: | - echo "Descargando archivos de docs-sp/html..." - aws s3 sync \ - s3://docs-sp/html/ \ - downloaded-files/ \ - --endpoint-url https://nyc3.digitaloceanspaces.com \ - --no-progress - - - name: List downloaded files - run: | - echo "==========================================" - echo "Archivos descargados:" - echo "==========================================" - ls -lh downloaded-files/ - echo "" - echo "==========================================" - echo "Archivos .tar.gz encontrados:" - echo "==========================================" - find downloaded-files/ -name "*.tar.gz" -type f -exec ls -lh {} \; - echo "" - echo "==========================================" - echo "Total de archivos descargados:" - echo "==========================================" - find downloaded-files/ -type f | wc -l From 309d28cd445cb7ee5f061403ce47866f341a7323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 6 Nov 2025 18:14:32 -0300 Subject: [PATCH 28/45] Fix Action --- .github/workflows/build-and-package.yml | 6 +++- Dockerfile | 38 ++++++++++++++++++------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 5be187c3..334b8cd8 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -77,9 +77,11 @@ jobs: build-nginx-image: name: Build and Push Nginx Image runs-on: ubuntu-latest - needs: + needs: - check-digitalocean-secrets if: needs.check-digitalocean-secrets.outputs.is_have_secrets == 'true' + env: + DEFAULT_BRANCH: main steps: - name: Checkout Repository @@ -120,3 +122,5 @@ jobs: push: true tags: ${{ vars.DIGITALOCEAN_REGISTRY }}/${{ vars.DOCKER_REPO_DOCS_SP }}:main file: ./Dockerfile + build-args: | + DEFAULT_BRANCH=${{ env.DEFAULT_BRANCH }} diff --git a/Dockerfile b/Dockerfile index bd806660..df24c7e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,39 @@ # Usar la última versión estable de nginx FROM nginx:stable +# Argumento para definir la rama/tag principal que se montará en la raíz +ARG DEFAULT_BRANCH=main + # Crear directorio temporal para los archivos comprimidos WORKDIR /tmp # Copiar todos los archivos tar.gz descargados de S3 COPY s3-downloads/*.tar.gz /tmp/ -# Descomprimir cada archivo tar.gz en su propio directorio dentro de nginx -# El directorio por defecto de nginx es /usr/share/nginx/html -RUN for file in /tmp/*.tar.gz; do \ - if [ -f "$file" ]; then \ - # Obtener el nombre base sin la extensión .tar.gz - dirname=$(basename "$file" .tar.gz); \ - echo "Descomprimiendo $file en directorio $dirname..."; \ - # Crear directorio específico y descomprimir - mkdir -p /usr/share/nginx/html/$dirname; \ - tar -xzf "$file" -C /usr/share/nginx/html/$dirname/; \ - fi \ +# Descomprimir archivos tar.gz +# Si existe el archivo de la rama principal, se descomprime en la raíz +# Los demás se descomprimen en sus propios directorios +RUN DEFAULT_FILE="docs-sp-${DEFAULT_BRANCH}.tar.gz" && \ + echo "Buscando archivo principal: $DEFAULT_FILE" && \ + # Primero verificar si existe el archivo principal y descomprimirlo en la raíz + if [ -f "/tmp/$DEFAULT_FILE" ]; then \ + echo "Descomprimiendo $DEFAULT_FILE en la raíz..."; \ + tar -xzf "/tmp/$DEFAULT_FILE" -C /usr/share/nginx/html/; \ + fi && \ + # Descomprimir los demás archivos en sus propios directorios + for file in /tmp/*.tar.gz; do \ + if [ -f "$file" ]; then \ + filename=$(basename "$file"); \ + # Saltar el archivo principal si ya se procesó + if [ "$filename" != "$DEFAULT_FILE" ]; then \ + dirname=$(basename "$file" .tar.gz); \ + # Eliminar el prefijo "docs-sp-" si existe + dirname=${dirname#docs-sp-}; \ + echo "Descomprimiendo $file en directorio $dirname..."; \ + mkdir -p /usr/share/nginx/html/$dirname; \ + tar -xzf "$file" -C /usr/share/nginx/html/$dirname/; \ + fi \ + fi \ done && \ # Limpiar los archivos comprimidos para reducir el tamaño de la imagen rm -f /tmp/*.tar.gz From 765221a184b2d2258f026d38f345916c3628ccc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 6 Nov 2025 18:23:27 -0300 Subject: [PATCH 29/45] Fix Action --- .github/workflows/build-and-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 334b8cd8..3f8af9ec 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -81,7 +81,7 @@ jobs: - check-digitalocean-secrets if: needs.check-digitalocean-secrets.outputs.is_have_secrets == 'true' env: - DEFAULT_BRANCH: main + DEFAULT_BRANCH: feature-1636-pack-doc steps: - name: Checkout Repository From 90a63467d7e864f37b93b1c894d216f784e7edbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Thu, 6 Nov 2025 18:36:53 -0300 Subject: [PATCH 30/45] Fix Action --- Dockerfile | 3 +++ nginx.conf | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index df24c7e1..a03678c5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,9 @@ WORKDIR /tmp # Copiar todos los archivos tar.gz descargados de S3 COPY s3-downloads/*.tar.gz /tmp/ +# Copiar configuración personalizada de nginx +COPY nginx.conf /etc/nginx/conf.d/default.conf + # Descomprimir archivos tar.gz # Si existe el archivo de la rama principal, se descomprime en la raíz # Los demás se descomprimen en sus propios directorios diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 00000000..fb59f66b --- /dev/null +++ b/nginx.conf @@ -0,0 +1,47 @@ +server { + listen 80; + server_name localhost; + + root /usr/share/nginx/html; + index index.html index.htm; + + # Logs + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + # Desactivar logs para favicon + location = /favicon.ico { + log_not_found off; + access_log off; + } + + # Desactivar logs para robots.txt + location = /robots.txt { + log_not_found off; + access_log off; + } + + # Configuración para archivos estáticos comunes (debe ir primero para mayor prioridad) + location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|json|xml|txt|pdf|map)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + try_files $uri =404; + } + + # Configuración para cada subdirectorio (otras ramas) + # Cada directorio se trata como una SPA independiente + location ~ ^/([^/]+)(/|$) { + set $branch_dir $1; + + # Primero intentar servir el archivo exacto + # Si no existe, intentar como directorio con index.html + # Si tampoco existe, servir el index.html del directorio raíz de esa rama (para SPAs) + try_files $uri $uri/ /$branch_dir/index.html =404; + } + + # Configuración para la raíz (rama principal) + # Esto debe ir al final para que tenga menor prioridad + location / { + try_files $uri $uri/ /index.html =404; + } +} From dbeeec8f24204018e1b18a5c2f04abde89043aa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Fri, 7 Nov 2025 09:25:06 -0300 Subject: [PATCH 31/45] Fix Action --- .github/workflows/build-and-package.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 3f8af9ec..832815ab 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -4,6 +4,8 @@ on: push: branches: - feature* + tags: + - '*' jobs: build-and-package: From 84beeeaebc524e24dbfaf24ad82c26e1cb5f1d97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Fri, 7 Nov 2025 09:39:44 -0300 Subject: [PATCH 32/45] Fix Action --- .github/workflows/build-and-package.yml | 4 ---- Dockerfile | 31 +++++++------------------ nginx.conf | 31 ++++++++++++------------- 3 files changed, 23 insertions(+), 43 deletions(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 832815ab..7a024007 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -82,8 +82,6 @@ jobs: needs: - check-digitalocean-secrets if: needs.check-digitalocean-secrets.outputs.is_have_secrets == 'true' - env: - DEFAULT_BRANCH: feature-1636-pack-doc steps: - name: Checkout Repository @@ -124,5 +122,3 @@ jobs: push: true tags: ${{ vars.DIGITALOCEAN_REGISTRY }}/${{ vars.DOCKER_REPO_DOCS_SP }}:main file: ./Dockerfile - build-args: | - DEFAULT_BRANCH=${{ env.DEFAULT_BRANCH }} diff --git a/Dockerfile b/Dockerfile index a03678c5..5a3af641 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,6 @@ # Usar la última versión estable de nginx FROM nginx:stable -# Argumento para definir la rama/tag principal que se montará en la raíz -ARG DEFAULT_BRANCH=main - # Crear directorio temporal para los archivos comprimidos WORKDIR /tmp @@ -14,28 +11,16 @@ COPY s3-downloads/*.tar.gz /tmp/ COPY nginx.conf /etc/nginx/conf.d/default.conf # Descomprimir archivos tar.gz -# Si existe el archivo de la rama principal, se descomprime en la raíz -# Los demás se descomprimen en sus propios directorios -RUN DEFAULT_FILE="docs-sp-${DEFAULT_BRANCH}.tar.gz" && \ - echo "Buscando archivo principal: $DEFAULT_FILE" && \ - # Primero verificar si existe el archivo principal y descomprimirlo en la raíz - if [ -f "/tmp/$DEFAULT_FILE" ]; then \ - echo "Descomprimiendo $DEFAULT_FILE en la raíz..."; \ - tar -xzf "/tmp/$DEFAULT_FILE" -C /usr/share/nginx/html/; \ - fi && \ - # Descomprimir los demás archivos en sus propios directorios - for file in /tmp/*.tar.gz; do \ +# Todos los archivos (incluyendo la rama principal) se descomprimen en sus propios subdirectorios +RUN for file in /tmp/*.tar.gz; do \ if [ -f "$file" ]; then \ filename=$(basename "$file"); \ - # Saltar el archivo principal si ya se procesó - if [ "$filename" != "$DEFAULT_FILE" ]; then \ - dirname=$(basename "$file" .tar.gz); \ - # Eliminar el prefijo "docs-sp-" si existe - dirname=${dirname#docs-sp-}; \ - echo "Descomprimiendo $file en directorio $dirname..."; \ - mkdir -p /usr/share/nginx/html/$dirname; \ - tar -xzf "$file" -C /usr/share/nginx/html/$dirname/; \ - fi \ + dirname=$(basename "$file" .tar.gz); \ + # Eliminar el prefijo "docs-sp-" si existe + dirname=${dirname#docs-sp-}; \ + echo "Descomprimiendo $file en directorio $dirname..."; \ + mkdir -p /usr/share/nginx/html/$dirname; \ + tar -xzf "$file" -C /usr/share/nginx/html/$dirname/; \ fi \ done && \ # Limpiar los archivos comprimidos para reducir el tamaño de la imagen diff --git a/nginx.conf b/nginx.conf index fb59f66b..5ee22c58 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,8 +1,10 @@ +# Configuración para subdominios +# Captura cualquier subdominio y lo mapea a su directorio correspondiente server { listen 80; - server_name localhost; + server_name ~^(?[^.]+)\.docs1\.dev\.solopcloud\.com$; - root /usr/share/nginx/html; + root /usr/share/nginx/html/$branch; index index.html index.htm; # Logs @@ -21,27 +23,24 @@ server { access_log off; } - # Configuración para archivos estáticos comunes (debe ir primero para mayor prioridad) + # Configuración para archivos estáticos comunes location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|json|xml|txt|pdf|map)$ { expires 1y; add_header Cache-Control "public, immutable"; try_files $uri =404; } - # Configuración para cada subdirectorio (otras ramas) - # Cada directorio se trata como una SPA independiente - location ~ ^/([^/]+)(/|$) { - set $branch_dir $1; - - # Primero intentar servir el archivo exacto - # Si no existe, intentar como directorio con index.html - # Si tampoco existe, servir el index.html del directorio raíz de esa rama (para SPAs) - try_files $uri $uri/ /$branch_dir/index.html =404; - } - - # Configuración para la raíz (rama principal) - # Esto debe ir al final para que tenga menor prioridad + # Configuración SPA: redirigir todo a index.html location / { try_files $uri $uri/ /index.html =404; } } + +# Configuración para el dominio principal (sin subdominio) +server { + listen 80 default_server; + server_name docs1.dev.solopcloud.com; + + # Redirigir a un subdominio por defecto (por ejemplo, la rama main) + return 301 http://main.docs1.dev.solopcloud.com$request_uri; +} From 79b94dde81ac5a4e3220944638a209230d2e5900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Fri, 7 Nov 2025 09:40:58 -0300 Subject: [PATCH 33/45] Fix Action --- .github/workflows/test.yml | 67 -------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 80fa8daa..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Test blog - -#on: -# push: -# pull_request: - -jobs: - build-test: - name: Test build using ${{ matrix.bundler }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - bundler: - - webpack - - vite - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - persist-credentials: false - submodules: true - - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: 9.1.1 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 20 - cache: pnpm - - - name: Install Deps - run: pnpm install --no-frozen-lockfile - - - name: Build Blog with ${{ matrix.bundler }} - env: - NODE_OPTIONS: --max_old_space_size=8192 - run: pnpm run build:${{ matrix.bundler }} - - linter-test: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - persist-credentials: false - submodules: true - - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: 9.1.1 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 20 - cache: pnpm - - - name: Install Deps - run: pnpm install --no-frozen-lockfile - - - name: Linter test - run: pnpm run lint From 2881f2d8606c0fd3beabddd160e45d243dda299b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Fri, 7 Nov 2025 10:16:49 -0300 Subject: [PATCH 34/45] Fix Action --- .github/workflows/build-and-package.yml | 6 ++ Dockerfile | 119 ++++++++++++++++++++++-- 2 files changed, 116 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 7a024007..88efb9fd 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -82,6 +82,9 @@ jobs: needs: - check-digitalocean-secrets if: needs.check-digitalocean-secrets.outputs.is_have_secrets == 'true' + env: + DEFAULT_BRANCH: feature-1636-pack-doc-2 + MAIN_DOMAIN: docs1.dev.solopcloud.com steps: - name: Checkout Repository @@ -122,3 +125,6 @@ jobs: push: true tags: ${{ vars.DIGITALOCEAN_REGISTRY }}/${{ vars.DOCKER_REPO_DOCS_SP }}:main file: ./Dockerfile + build-args: | + DEFAULT_BRANCH=${{ env.DEFAULT_BRANCH }} + MAIN_DOMAIN=${{ env.MAIN_DOMAIN }} diff --git a/Dockerfile b/Dockerfile index 5a3af641..999765e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,129 @@ # Usar la última versión estable de nginx FROM nginx:stable +# Argumentos para configuración +ARG DEFAULT_BRANCH=main +ARG MAIN_DOMAIN=docs1.dev.solopcloud.com + # Crear directorio temporal para los archivos comprimidos WORKDIR /tmp # Copiar todos los archivos tar.gz descargados de S3 COPY s3-downloads/*.tar.gz /tmp/ -# Copiar configuración personalizada de nginx -COPY nginx.conf /etc/nginx/conf.d/default.conf +# Generar configuración de nginx dinámicamente y descomprimir archivos +RUN echo "=== Configuración ===" && \ + echo "DEFAULT_BRANCH: ${DEFAULT_BRANCH}" && \ + echo "MAIN_DOMAIN: ${MAIN_DOMAIN}" && \ + echo "" && \ + echo "Generando configuración de nginx dinámicamente..." && \ + # Iniciar el archivo de configuración + cat > /etc/nginx/conf.d/default.conf << 'EOF_HEADER' +# Configuración generada dinámicamente para subdominios -# Descomprimir archivos tar.gz -# Todos los archivos (incluyendo la rama principal) se descomprimen en sus propios subdirectorios -RUN for file in /tmp/*.tar.gz; do \ +EOF_HEADER + # Procesar cada archivo tar.gz + for file in /tmp/*.tar.gz; do \ if [ -f "$file" ]; then \ filename=$(basename "$file"); \ dirname=$(basename "$file" .tar.gz); \ # Eliminar el prefijo "docs-sp-" si existe - dirname=${dirname#docs-sp-}; \ - echo "Descomprimiendo $file en directorio $dirname..."; \ - mkdir -p /usr/share/nginx/html/$dirname; \ - tar -xzf "$file" -C /usr/share/nginx/html/$dirname/; \ + branch=${dirname#docs-sp-}; \ + echo "Procesando: $branch"; \ + # Descomprimir el archivo + mkdir -p /usr/share/nginx/html/$branch; \ + tar -xzf "$file" -C /usr/share/nginx/html/$branch/; \ + # Generar configuración de nginx para este branch + # Si es el DEFAULT_BRANCH, configurar tanto el dominio principal como el subdominio + if [ "$branch" = "${DEFAULT_BRANCH}" ]; then \ + echo "Configurando $branch como dominio principal (${MAIN_DOMAIN}) y subdominio (${branch}.${MAIN_DOMAIN})"; \ + cat >> /etc/nginx/conf.d/default.conf << EOF_MAIN +# Configuración para el dominio principal - rama ${DEFAULT_BRANCH} +server { + listen 80 default_server; + server_name ${MAIN_DOMAIN}; + + root /usr/share/nginx/html/$branch; + index index.html index.htm; + + # Logs + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + # Desactivar logs para favicon + location = /favicon.ico { + log_not_found off; + access_log off; + } + + # Desactivar logs para robots.txt + location = /robots.txt { + log_not_found off; + access_log off; + } + + # Configuración para archivos estáticos comunes + location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|json|xml|txt|pdf|map)\$ { + expires 1y; + add_header Cache-Control "public, immutable"; + try_files \$uri =404; + } + + # Configuración SPA: redirigir todo a index.html + location / { + try_files \$uri \$uri/ /index.html =404; + } +} + +EOF_MAIN + fi; \ + # Configurar subdominio para todas las ramas (incluyendo la principal) + echo "Configurando subdominio: ${branch}.${MAIN_DOMAIN}"; \ + cat >> /etc/nginx/conf.d/default.conf << EOF_SERVER +# Configuración para $branch +server { + listen 80; + server_name ${branch}.${MAIN_DOMAIN}; + + root /usr/share/nginx/html/$branch; + index index.html index.htm; + + # Logs + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + # Desactivar logs para favicon + location = /favicon.ico { + log_not_found off; + access_log off; + } + + # Desactivar logs para robots.txt + location = /robots.txt { + log_not_found off; + access_log off; + } + + # Configuración para archivos estáticos comunes + location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|json|xml|txt|pdf|map)\$ { + expires 1y; + add_header Cache-Control "public, immutable"; + try_files \$uri =404; + } + + # Configuración SPA: redirigir todo a index.html + location / { + try_files \$uri \$uri/ /index.html =404; + } +} + +EOF_SERVER fi \ done && \ + echo "" && \ + echo "=== Configuración de nginx generada ===" && \ + cat /etc/nginx/conf.d/default.conf && \ + echo "========================================" && \ # Limpiar los archivos comprimidos para reducir el tamaño de la imagen rm -f /tmp/*.tar.gz From 0895434ba6ac8871e0f1338b033b37bcf716045f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Fri, 7 Nov 2025 10:30:59 -0300 Subject: [PATCH 35/45] Fix Action --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 999765e1..7ba472af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,7 @@ RUN echo "=== Configuración ===" && \ # Configuración generada dinámicamente para subdominios EOF_HEADER + && \ # Procesar cada archivo tar.gz for file in /tmp/*.tar.gz; do \ if [ -f "$file" ]; then \ From 233a7d2e2c67d07a459478b1c27c0c88d7bd36ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Fri, 7 Nov 2025 10:37:01 -0300 Subject: [PATCH 36/45] Fix Action --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7ba472af..c62efb88 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,11 +18,10 @@ RUN echo "=== Configuración ===" && \ echo "" && \ echo "Generando configuración de nginx dinámicamente..." && \ # Iniciar el archivo de configuración - cat > /etc/nginx/conf.d/default.conf << 'EOF_HEADER' + cat > /etc/nginx/conf.d/default.conf <<'EOF_HEADER' && \ # Configuración generada dinámicamente para subdominios EOF_HEADER - && \ # Procesar cada archivo tar.gz for file in /tmp/*.tar.gz; do \ if [ -f "$file" ]; then \ From 2b005ac8957241b946138f6b1aabb62fe30a2eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Fri, 7 Nov 2025 10:40:14 -0300 Subject: [PATCH 37/45] Fix Action --- .github/workflows/build-and-package.yml | 96 ++++++++++++------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 88efb9fd..228a45af 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -8,57 +8,57 @@ on: - '*' jobs: - build-and-package: - runs-on: ubuntu-latest - - env: - BRANCH_NAME: ${{ github.ref_name }} - PACKAGE_NAME: docs-sp-${{ github.ref_name }}.tar.gz - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: true - fetch-depth: 0 - - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: 9.1.1 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 20 - cache: pnpm - - - name: Install Deps - run: pnpm install --no-frozen-lockfile - - - name: Build Blog - env: - NODE_OPTIONS: --max_old_space_size=8192 - run: pnpm run build:webpack - - - name: Compress Build Output (tar.gz) - run: tar -czvf $PACKAGE_NAME -C dist . - - - name: Upload site pack to S3 - uses: BetaHuhn/do-spaces-action@v2 - with: - access_key: ${{ vars.AWS_ACCESS_KEY_ID}} - secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - space_name: 'docs-sp' - space_region: 'nyc3' - source: ${{ env.PACKAGE_NAME }} - out_dir: 'html/' - overwrite: true +# build-and-package: +# runs-on: ubuntu-latest +# +# env: +# BRANCH_NAME: ${{ github.ref_name }} +# PACKAGE_NAME: docs-sp-${{ github.ref_name }}.tar.gz +# +# steps: +# - name: Checkout +# uses: actions/checkout@v3 +# with: +# submodules: true +# fetch-depth: 0 +# +# - name: Install pnpm +# uses: pnpm/action-setup@v4 +# with: +# version: 9.1.1 +# +# - name: Setup Node.js +# uses: actions/setup-node@v3 +# with: +# node-version: 20 +# cache: pnpm +# +# - name: Install Deps +# run: pnpm install --no-frozen-lockfile +# +# - name: Build Blog +# env: +# NODE_OPTIONS: --max_old_space_size=8192 +# run: pnpm run build:webpack +# +# - name: Compress Build Output (tar.gz) +# run: tar -czvf $PACKAGE_NAME -C dist . +# +# - name: Upload site pack to S3 +# uses: BetaHuhn/do-spaces-action@v2 +# with: +# access_key: ${{ vars.AWS_ACCESS_KEY_ID}} +# secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} +# space_name: 'docs-sp' +# space_region: 'nyc3' +# source: ${{ env.PACKAGE_NAME }} +# out_dir: 'html/' +# overwrite: true check-digitalocean-secrets: name: Check if Digitalocean registry information was set on secrets - needs: - - build-and-package + # needs: + # - build-and-package runs-on: ubuntu-latest outputs: is_have_secrets: ${{ steps.check_digitalocean_secrets_job.outputs.is_have_secrets }} From b49f3cf45062572ad0d0876b7cc68c07a2fed619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Fri, 7 Nov 2025 10:43:14 -0300 Subject: [PATCH 38/45] Fix Action --- Dockerfile | 124 ++++----------------------------------- generate-nginx-config.sh | 124 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+), 114 deletions(-) create mode 100644 generate-nginx-config.sh diff --git a/Dockerfile b/Dockerfile index c62efb88..cdb561e8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,127 +5,23 @@ FROM nginx:stable ARG DEFAULT_BRANCH=main ARG MAIN_DOMAIN=docs1.dev.solopcloud.com +# Convertir los ARGs en variables de entorno +ENV DEFAULT_BRANCH=${DEFAULT_BRANCH} +ENV MAIN_DOMAIN=${MAIN_DOMAIN} + # Crear directorio temporal para los archivos comprimidos WORKDIR /tmp # Copiar todos los archivos tar.gz descargados de S3 COPY s3-downloads/*.tar.gz /tmp/ -# Generar configuración de nginx dinámicamente y descomprimir archivos -RUN echo "=== Configuración ===" && \ - echo "DEFAULT_BRANCH: ${DEFAULT_BRANCH}" && \ - echo "MAIN_DOMAIN: ${MAIN_DOMAIN}" && \ - echo "" && \ - echo "Generando configuración de nginx dinámicamente..." && \ - # Iniciar el archivo de configuración - cat > /etc/nginx/conf.d/default.conf <<'EOF_HEADER' && \ -# Configuración generada dinámicamente para subdominios - -EOF_HEADER - # Procesar cada archivo tar.gz - for file in /tmp/*.tar.gz; do \ - if [ -f "$file" ]; then \ - filename=$(basename "$file"); \ - dirname=$(basename "$file" .tar.gz); \ - # Eliminar el prefijo "docs-sp-" si existe - branch=${dirname#docs-sp-}; \ - echo "Procesando: $branch"; \ - # Descomprimir el archivo - mkdir -p /usr/share/nginx/html/$branch; \ - tar -xzf "$file" -C /usr/share/nginx/html/$branch/; \ - # Generar configuración de nginx para este branch - # Si es el DEFAULT_BRANCH, configurar tanto el dominio principal como el subdominio - if [ "$branch" = "${DEFAULT_BRANCH}" ]; then \ - echo "Configurando $branch como dominio principal (${MAIN_DOMAIN}) y subdominio (${branch}.${MAIN_DOMAIN})"; \ - cat >> /etc/nginx/conf.d/default.conf << EOF_MAIN -# Configuración para el dominio principal - rama ${DEFAULT_BRANCH} -server { - listen 80 default_server; - server_name ${MAIN_DOMAIN}; - - root /usr/share/nginx/html/$branch; - index index.html index.htm; - - # Logs - access_log /var/log/nginx/access.log; - error_log /var/log/nginx/error.log; - - # Desactivar logs para favicon - location = /favicon.ico { - log_not_found off; - access_log off; - } - - # Desactivar logs para robots.txt - location = /robots.txt { - log_not_found off; - access_log off; - } - - # Configuración para archivos estáticos comunes - location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|json|xml|txt|pdf|map)\$ { - expires 1y; - add_header Cache-Control "public, immutable"; - try_files \$uri =404; - } - - # Configuración SPA: redirigir todo a index.html - location / { - try_files \$uri \$uri/ /index.html =404; - } -} - -EOF_MAIN - fi; \ - # Configurar subdominio para todas las ramas (incluyendo la principal) - echo "Configurando subdominio: ${branch}.${MAIN_DOMAIN}"; \ - cat >> /etc/nginx/conf.d/default.conf << EOF_SERVER -# Configuración para $branch -server { - listen 80; - server_name ${branch}.${MAIN_DOMAIN}; - - root /usr/share/nginx/html/$branch; - index index.html index.htm; - - # Logs - access_log /var/log/nginx/access.log; - error_log /var/log/nginx/error.log; - - # Desactivar logs para favicon - location = /favicon.ico { - log_not_found off; - access_log off; - } - - # Desactivar logs para robots.txt - location = /robots.txt { - log_not_found off; - access_log off; - } - - # Configuración para archivos estáticos comunes - location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|json|xml|txt|pdf|map)\$ { - expires 1y; - add_header Cache-Control "public, immutable"; - try_files \$uri =404; - } - - # Configuración SPA: redirigir todo a index.html - location / { - try_files \$uri \$uri/ /index.html =404; - } -} +# Copiar el script de generación de configuración +COPY generate-nginx-config.sh /tmp/generate-nginx-config.sh -EOF_SERVER - fi \ - done && \ - echo "" && \ - echo "=== Configuración de nginx generada ===" && \ - cat /etc/nginx/conf.d/default.conf && \ - echo "========================================" && \ - # Limpiar los archivos comprimidos para reducir el tamaño de la imagen - rm -f /tmp/*.tar.gz +# Dar permisos de ejecución y ejecutar el script +RUN chmod +x /tmp/generate-nginx-config.sh && \ + /tmp/generate-nginx-config.sh && \ + rm /tmp/generate-nginx-config.sh # Exponer el puerto 80 EXPOSE 80 diff --git a/generate-nginx-config.sh b/generate-nginx-config.sh new file mode 100644 index 00000000..39618664 --- /dev/null +++ b/generate-nginx-config.sh @@ -0,0 +1,124 @@ +#!/bin/bash +set -e + +echo "=== Configuración ===" +echo "DEFAULT_BRANCH: ${DEFAULT_BRANCH}" +echo "MAIN_DOMAIN: ${MAIN_DOMAIN}" +echo "" +echo "Generando configuración de nginx dinámicamente..." + +# Iniciar el archivo de configuración +cat > /etc/nginx/conf.d/default.conf << 'EOF_HEADER' +# Configuración generada dinámicamente para subdominios + +EOF_HEADER + +# Procesar cada archivo tar.gz +for file in /tmp/*.tar.gz; do + if [ -f "$file" ]; then + filename=$(basename "$file") + dirname=$(basename "$file" .tar.gz) + # Eliminar el prefijo "docs-sp-" si existe + branch=${dirname#docs-sp-} + echo "Procesando: $branch" + + # Descomprimir el archivo + mkdir -p /usr/share/nginx/html/$branch + tar -xzf "$file" -C /usr/share/nginx/html/$branch/ + + # Generar configuración de nginx para este branch + # Si es el DEFAULT_BRANCH, configurar tanto el dominio principal como el subdominio + if [ "$branch" = "${DEFAULT_BRANCH}" ]; then + echo "Configurando $branch como dominio principal (${MAIN_DOMAIN}) y subdominio (${branch}.${MAIN_DOMAIN})" + cat >> /etc/nginx/conf.d/default.conf << EOF_MAIN +# Configuración para el dominio principal - rama ${DEFAULT_BRANCH} +server { + listen 80 default_server; + server_name ${MAIN_DOMAIN}; + + root /usr/share/nginx/html/$branch; + index index.html index.htm; + + # Logs + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + # Desactivar logs para favicon + location = /favicon.ico { + log_not_found off; + access_log off; + } + + # Desactivar logs para robots.txt + location = /robots.txt { + log_not_found off; + access_log off; + } + + # Configuración para archivos estáticos comunes + location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|json|xml|txt|pdf|map)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + try_files \$uri =404; + } + + # Configuración SPA: redirigir todo a index.html + location / { + try_files \$uri \$uri/ /index.html =404; + } +} + +EOF_MAIN + fi + + # Configurar subdominio para todas las ramas (incluyendo la principal) + echo "Configurando subdominio: ${branch}.${MAIN_DOMAIN}" + cat >> /etc/nginx/conf.d/default.conf << EOF_SERVER +# Configuración para $branch +server { + listen 80; + server_name ${branch}.${MAIN_DOMAIN}; + + root /usr/share/nginx/html/$branch; + index index.html index.htm; + + # Logs + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + # Desactivar logs para favicon + location = /favicon.ico { + log_not_found off; + access_log off; + } + + # Desactivar logs para robots.txt + location = /robots.txt { + log_not_found off; + access_log off; + } + + # Configuración para archivos estáticos comunes + location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|json|xml|txt|pdf|map)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + try_files \$uri =404; + } + + # Configuración SPA: redirigir todo a index.html + location / { + try_files \$uri \$uri/ /index.html =404; + } +} + +EOF_SERVER + fi +done + +echo "" +echo "=== Configuración de nginx generada ===" +cat /etc/nginx/conf.d/default.conf +echo "========================================" + +# Limpiar los archivos comprimidos para reducir el tamaño de la imagen +rm -f /tmp/*.tar.gz From 97fa24f82e972db625a5917e81cf28b682cdd9ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Fri, 7 Nov 2025 11:03:10 -0300 Subject: [PATCH 39/45] Fix Action --- .github/workflows/build-and-package.yml | 96 ++++++++++++------------- docker-compose.yml | 17 ----- docker-compose/.env | 7 ++ docker-compose/docker-compose.yml | 29 ++++++++ src/docs/test-page/README.md | 4 ++ 5 files changed, 88 insertions(+), 65 deletions(-) delete mode 100644 docker-compose.yml create mode 100644 docker-compose/.env create mode 100644 docker-compose/docker-compose.yml create mode 100644 src/docs/test-page/README.md diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 228a45af..88efb9fd 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -8,57 +8,57 @@ on: - '*' jobs: -# build-and-package: -# runs-on: ubuntu-latest -# -# env: -# BRANCH_NAME: ${{ github.ref_name }} -# PACKAGE_NAME: docs-sp-${{ github.ref_name }}.tar.gz -# -# steps: -# - name: Checkout -# uses: actions/checkout@v3 -# with: -# submodules: true -# fetch-depth: 0 -# -# - name: Install pnpm -# uses: pnpm/action-setup@v4 -# with: -# version: 9.1.1 -# -# - name: Setup Node.js -# uses: actions/setup-node@v3 -# with: -# node-version: 20 -# cache: pnpm -# -# - name: Install Deps -# run: pnpm install --no-frozen-lockfile -# -# - name: Build Blog -# env: -# NODE_OPTIONS: --max_old_space_size=8192 -# run: pnpm run build:webpack -# -# - name: Compress Build Output (tar.gz) -# run: tar -czvf $PACKAGE_NAME -C dist . -# -# - name: Upload site pack to S3 -# uses: BetaHuhn/do-spaces-action@v2 -# with: -# access_key: ${{ vars.AWS_ACCESS_KEY_ID}} -# secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} -# space_name: 'docs-sp' -# space_region: 'nyc3' -# source: ${{ env.PACKAGE_NAME }} -# out_dir: 'html/' -# overwrite: true + build-and-package: + runs-on: ubuntu-latest + + env: + BRANCH_NAME: ${{ github.ref_name }} + PACKAGE_NAME: docs-sp-${{ github.ref_name }}.tar.gz + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.1.1 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + cache: pnpm + + - name: Install Deps + run: pnpm install --no-frozen-lockfile + + - name: Build Blog + env: + NODE_OPTIONS: --max_old_space_size=8192 + run: pnpm run build:webpack + + - name: Compress Build Output (tar.gz) + run: tar -czvf $PACKAGE_NAME -C dist . + + - name: Upload site pack to S3 + uses: BetaHuhn/do-spaces-action@v2 + with: + access_key: ${{ vars.AWS_ACCESS_KEY_ID}} + secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + space_name: 'docs-sp' + space_region: 'nyc3' + source: ${{ env.PACKAGE_NAME }} + out_dir: 'html/' + overwrite: true check-digitalocean-secrets: name: Check if Digitalocean registry information was set on secrets - # needs: - # - build-and-package + needs: + - build-and-package runs-on: ubuntu-latest outputs: is_have_secrets: ${{ steps.check_digitalocean_secrets_job.outputs.is_have_secrets }} diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index d9d86d92..00000000 --- a/docker-compose.yml +++ /dev/null @@ -1,17 +0,0 @@ -version: '3.8' - -services: - docs-sp-nginx: - image: registry.digitalocean.com/spuy/docs-sp:main - container_name: docs-sp-nginx - ports: - - "8081:80" - restart: unless-stopped - environment: - - TZ=America/Montevideo - healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:80"] - interval: 30s - timeout: 10s - retries: 3 - start_period: 10s diff --git a/docker-compose/.env b/docker-compose/.env new file mode 100644 index 00000000..1ac9bf70 --- /dev/null +++ b/docker-compose/.env @@ -0,0 +1,7 @@ + +GENERAL_VIRTUAL_HOST="docs1.dev.solopcloud.com" +GENERAL_LETSENCRYPT_EMAIL=${GENERAL_STACK_NAME}@solopcloud.com + +# Networks +DEFAULT_NETWORK="proxy.network" +IS_EXTERNAL_NETWORK=true \ No newline at end of file diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml new file mode 100644 index 00000000..716da04f --- /dev/null +++ b/docker-compose/docker-compose.yml @@ -0,0 +1,29 @@ +services: + docs-sp-nginx: + image: registry.digitalocean.com/spuy/docs-sp:main + container_name: docs-sp-nginx + ports: + - "8081:80" + restart: unless-stopped + environment: + TZ: America/Montevideo + VIRTUAL_HOST: "*.${GENERAL_VIRTUAL_HOST}" + VIRTUAL_PORT: 80 + LETSENCRYPT_HOST: "*.${GENERAL_VIRTUAL_HOST}" + LETSENCRYPT_EMAIL: test@solopcloud.com + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:80"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 10s + networks: + - private_network + - shared_network + +networks: + shared_network: + name: ${DEFAULT_NETWORK} + external: ${IS_EXTERNAL_NETWORK} + private_network: + name: docs1.network \ No newline at end of file diff --git a/src/docs/test-page/README.md b/src/docs/test-page/README.md new file mode 100644 index 00000000..12863513 --- /dev/null +++ b/src/docs/test-page/README.md @@ -0,0 +1,4 @@ + +### Página de Prueba - Nuevo Sitio + +Página de prueba para nuevo sitio \ No newline at end of file From 578eaa26c3bb10c2bcb768d498290a6a74c60842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Fri, 7 Nov 2025 14:34:26 -0300 Subject: [PATCH 40/45] Fix Action --- .github/workflows/build-and-package.yml | 2 - Dockerfile | 2 - docker-compose/docker-compose.yml | 4 +- generate-nginx-config.sh | 133 +++++++++++------------- 4 files changed, 63 insertions(+), 78 deletions(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 88efb9fd..afc0e1d8 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -84,7 +84,6 @@ jobs: if: needs.check-digitalocean-secrets.outputs.is_have_secrets == 'true' env: DEFAULT_BRANCH: feature-1636-pack-doc-2 - MAIN_DOMAIN: docs1.dev.solopcloud.com steps: - name: Checkout Repository @@ -127,4 +126,3 @@ jobs: file: ./Dockerfile build-args: | DEFAULT_BRANCH=${{ env.DEFAULT_BRANCH }} - MAIN_DOMAIN=${{ env.MAIN_DOMAIN }} diff --git a/Dockerfile b/Dockerfile index cdb561e8..c930aaa3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,11 +3,9 @@ FROM nginx:stable # Argumentos para configuración ARG DEFAULT_BRANCH=main -ARG MAIN_DOMAIN=docs1.dev.solopcloud.com # Convertir los ARGs en variables de entorno ENV DEFAULT_BRANCH=${DEFAULT_BRANCH} -ENV MAIN_DOMAIN=${MAIN_DOMAIN} # Crear directorio temporal para los archivos comprimidos WORKDIR /tmp diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index 716da04f..692e6a63 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -7,9 +7,9 @@ services: restart: unless-stopped environment: TZ: America/Montevideo - VIRTUAL_HOST: "*.${GENERAL_VIRTUAL_HOST}" + VIRTUAL_HOST: "${GENERAL_VIRTUAL_HOST}" VIRTUAL_PORT: 80 - LETSENCRYPT_HOST: "*.${GENERAL_VIRTUAL_HOST}" + LETSENCRYPT_HOST: "${GENERAL_VIRTUAL_HOST}" LETSENCRYPT_EMAIL: test@solopcloud.com healthcheck: test: ["CMD", "curl", "-f", "http://localhost:80"] diff --git a/generate-nginx-config.sh b/generate-nginx-config.sh index 39618664..18eb6873 100644 --- a/generate-nginx-config.sh +++ b/generate-nginx-config.sh @@ -3,40 +3,18 @@ set -e echo "=== Configuración ===" echo "DEFAULT_BRANCH: ${DEFAULT_BRANCH}" -echo "MAIN_DOMAIN: ${MAIN_DOMAIN}" echo "" echo "Generando configuración de nginx dinámicamente..." -# Iniciar el archivo de configuración +# Iniciar el archivo de configuración con el bloque server principal cat > /etc/nginx/conf.d/default.conf << 'EOF_HEADER' -# Configuración generada dinámicamente para subdominios +# Configuración generada dinámicamente para múltiples ramas/tags -EOF_HEADER - -# Procesar cada archivo tar.gz -for file in /tmp/*.tar.gz; do - if [ -f "$file" ]; then - filename=$(basename "$file") - dirname=$(basename "$file" .tar.gz) - # Eliminar el prefijo "docs-sp-" si existe - branch=${dirname#docs-sp-} - echo "Procesando: $branch" - - # Descomprimir el archivo - mkdir -p /usr/share/nginx/html/$branch - tar -xzf "$file" -C /usr/share/nginx/html/$branch/ - - # Generar configuración de nginx para este branch - # Si es el DEFAULT_BRANCH, configurar tanto el dominio principal como el subdominio - if [ "$branch" = "${DEFAULT_BRANCH}" ]; then - echo "Configurando $branch como dominio principal (${MAIN_DOMAIN}) y subdominio (${branch}.${MAIN_DOMAIN})" - cat >> /etc/nginx/conf.d/default.conf << EOF_MAIN -# Configuración para el dominio principal - rama ${DEFAULT_BRANCH} server { - listen 80 default_server; - server_name ${MAIN_DOMAIN}; + listen 80; + server_name localhost; - root /usr/share/nginx/html/$branch; + root /usr/share/nginx/html; index index.html index.htm; # Logs @@ -55,70 +33,81 @@ server { access_log off; } - # Configuración para archivos estáticos comunes + # Configuración para archivos estáticos comunes (debe ir primero para mayor prioridad) location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|json|xml|txt|pdf|map)$ { expires 1y; add_header Cache-Control "public, immutable"; - try_files \$uri =404; + try_files $uri =404; } - # Configuración SPA: redirigir todo a index.html - location / { - try_files \$uri \$uri/ /index.html =404; - } -} - -EOF_MAIN - fi - - # Configurar subdominio para todas las ramas (incluyendo la principal) - echo "Configurando subdominio: ${branch}.${MAIN_DOMAIN}" - cat >> /etc/nginx/conf.d/default.conf << EOF_SERVER -# Configuración para $branch -server { - listen 80; - server_name ${branch}.${MAIN_DOMAIN}; - - root /usr/share/nginx/html/$branch; - index index.html index.htm; +EOF_HEADER - # Logs - access_log /var/log/nginx/access.log; - error_log /var/log/nginx/error.log; +# Procesar cada archivo tar.gz y descomprimir +echo "" +echo "=== Descomprimiendo archivos ===" +for file in /tmp/*.tar.gz; do + if [ -f "$file" ]; then + filename=$(basename "$file") + dirname=$(basename "$file" .tar.gz) + # Eliminar el prefijo "docs-sp-" si existe + branch=${dirname#docs-sp-} + echo "Procesando: $branch" - # Desactivar logs para favicon - location = /favicon.ico { - log_not_found off; - access_log off; - } + # Si es el DEFAULT_BRANCH, descomprimir en la raíz + if [ "$branch" = "${DEFAULT_BRANCH}" ]; then + echo " -> Descomprimiendo en la raíz (rama principal)" + tar -xzf "$file" -C /usr/share/nginx/html/ + else + # Descomprimir en su propio subdirectorio + echo " -> Descomprimiendo en /$branch/" + mkdir -p /usr/share/nginx/html/$branch + tar -xzf "$file" -C /usr/share/nginx/html/$branch/ + fi + fi +done - # Desactivar logs para robots.txt - location = /robots.txt { - log_not_found off; - access_log off; +# Generar las configuraciones de location para cada directorio (excepto la raíz) +echo "" +echo "=== Generando configuraciones de location ===" +for dir in /usr/share/nginx/html/*/; do + if [ -d "$dir" ]; then + branch=$(basename "$dir") + echo "Configurando location para: /$branch/" + + # Agregar location para esta rama + cat >> /etc/nginx/conf.d/default.conf << EOF_LOCATION + # Configuración para /$branch/ (SPA) + location ~ ^/$branch(/|$) { + alias /usr/share/nginx/html/$branch/; + index index.html index.htm; + + # Intentar servir el archivo, si no existe servir index.html de esa rama + try_files \$uri \$uri/ /$branch/index.html =404; } - # Configuración para archivos estáticos comunes - location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|json|xml|txt|pdf|map)$ { - expires 1y; - add_header Cache-Control "public, immutable"; - try_files \$uri =404; - } +EOF_LOCATION + fi +done - # Configuración SPA: redirigir todo a index.html +# Cerrar el bloque server y agregar configuración para la raíz (rama principal) +cat >> /etc/nginx/conf.d/default.conf << 'EOF_FOOTER' + # Configuración para la raíz (rama principal) + # Esto debe ir al final para que tenga menor prioridad location / { - try_files \$uri \$uri/ /index.html =404; + try_files $uri $uri/ /index.html =404; } } - -EOF_SERVER - fi -done +EOF_FOOTER echo "" echo "=== Configuración de nginx generada ===" cat /etc/nginx/conf.d/default.conf echo "========================================" +echo "" +echo "=== Estructura de directorios ===" +ls -la /usr/share/nginx/html/ +echo "========================================" + # Limpiar los archivos comprimidos para reducir el tamaño de la imagen rm -f /tmp/*.tar.gz From ff903657a84afa03b95e3f65aed80823162397bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Fri, 7 Nov 2025 15:12:08 -0300 Subject: [PATCH 41/45] Fix Action --- Dockerfile | 13 +++-- configure-base-paths.sh | 63 ++++++++++++++++++++++ generate-nginx-config.sh | 113 --------------------------------------- nginx.conf | 31 +++++------ 4 files changed, 87 insertions(+), 133 deletions(-) create mode 100644 configure-base-paths.sh delete mode 100644 generate-nginx-config.sh diff --git a/Dockerfile b/Dockerfile index c930aaa3..d1012d5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,13 +13,16 @@ WORKDIR /tmp # Copiar todos los archivos tar.gz descargados de S3 COPY s3-downloads/*.tar.gz /tmp/ -# Copiar el script de generación de configuración -COPY generate-nginx-config.sh /tmp/generate-nginx-config.sh +# Copiar configuración estática de nginx +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# Copiar el script de configuración de base paths +COPY configure-base-paths.sh /tmp/configure-base-paths.sh # Dar permisos de ejecución y ejecutar el script -RUN chmod +x /tmp/generate-nginx-config.sh && \ - /tmp/generate-nginx-config.sh && \ - rm /tmp/generate-nginx-config.sh +RUN chmod +x /tmp/configure-base-paths.sh && \ + /tmp/configure-base-paths.sh && \ + rm /tmp/configure-base-paths.sh # Exponer el puerto 80 EXPOSE 80 diff --git a/configure-base-paths.sh b/configure-base-paths.sh new file mode 100644 index 00000000..2924803e --- /dev/null +++ b/configure-base-paths.sh @@ -0,0 +1,63 @@ +#!/bin/bash +set -e + +DEFAULT_BRANCH="${DEFAULT_BRANCH:-main}" + +echo "=== Configurando base paths para cada directorio ===" +echo "DEFAULT_BRANCH: ${DEFAULT_BRANCH}" +echo "" + +# Procesar cada archivo tar.gz descargado +for file in /tmp/*.tar.gz; do + if [ -f "$file" ]; then + filename=$(basename "$file") + dirname=$(basename "$file" .tar.gz) + # Eliminar el prefijo "docs-sp-" si existe + branch=${dirname#docs-sp-} + + echo "Procesando: $branch" + + # Determinar el base path para esta rama + if [ "$branch" = "${DEFAULT_BRANCH}" ]; then + BASE_PATH="/" + TARGET_DIR="/usr/share/nginx/html" + echo " -> Base path: / (raíz - rama principal)" + else + BASE_PATH="/${branch}/" + TARGET_DIR="/usr/share/nginx/html/${branch}" + echo " -> Base path: ${BASE_PATH}" + fi + + # Crear el directorio de destino + mkdir -p "${TARGET_DIR}" + + # Descomprimir + echo " -> Descomprimiendo en ${TARGET_DIR}" + tar -xzf "$file" -C "${TARGET_DIR}/" + + # Agregar/modificar el base tag en todos los archivos HTML + echo " -> Configurando base path en archivos HTML" + find "${TARGET_DIR}" -type f -name "*.html" | while read html_file; do + # Verificar si ya existe un tag + if grep -q " + sed -i "s||\n |" "$html_file" + fi + done + + echo " -> ✓ Completado" + echo "" + fi +done + +echo "=== Estructura de directorios final ===" +ls -la /usr/share/nginx/html/ +echo "" + +# Limpiar los archivos comprimidos +rm -f /tmp/*.tar.gz + +echo "=== Configuración completada ===" diff --git a/generate-nginx-config.sh b/generate-nginx-config.sh deleted file mode 100644 index 18eb6873..00000000 --- a/generate-nginx-config.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/bash -set -e - -echo "=== Configuración ===" -echo "DEFAULT_BRANCH: ${DEFAULT_BRANCH}" -echo "" -echo "Generando configuración de nginx dinámicamente..." - -# Iniciar el archivo de configuración con el bloque server principal -cat > /etc/nginx/conf.d/default.conf << 'EOF_HEADER' -# Configuración generada dinámicamente para múltiples ramas/tags - -server { - listen 80; - server_name localhost; - - root /usr/share/nginx/html; - index index.html index.htm; - - # Logs - access_log /var/log/nginx/access.log; - error_log /var/log/nginx/error.log; - - # Desactivar logs para favicon - location = /favicon.ico { - log_not_found off; - access_log off; - } - - # Desactivar logs para robots.txt - location = /robots.txt { - log_not_found off; - access_log off; - } - - # Configuración para archivos estáticos comunes (debe ir primero para mayor prioridad) - location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|json|xml|txt|pdf|map)$ { - expires 1y; - add_header Cache-Control "public, immutable"; - try_files $uri =404; - } - -EOF_HEADER - -# Procesar cada archivo tar.gz y descomprimir -echo "" -echo "=== Descomprimiendo archivos ===" -for file in /tmp/*.tar.gz; do - if [ -f "$file" ]; then - filename=$(basename "$file") - dirname=$(basename "$file" .tar.gz) - # Eliminar el prefijo "docs-sp-" si existe - branch=${dirname#docs-sp-} - echo "Procesando: $branch" - - # Si es el DEFAULT_BRANCH, descomprimir en la raíz - if [ "$branch" = "${DEFAULT_BRANCH}" ]; then - echo " -> Descomprimiendo en la raíz (rama principal)" - tar -xzf "$file" -C /usr/share/nginx/html/ - else - # Descomprimir en su propio subdirectorio - echo " -> Descomprimiendo en /$branch/" - mkdir -p /usr/share/nginx/html/$branch - tar -xzf "$file" -C /usr/share/nginx/html/$branch/ - fi - fi -done - -# Generar las configuraciones de location para cada directorio (excepto la raíz) -echo "" -echo "=== Generando configuraciones de location ===" -for dir in /usr/share/nginx/html/*/; do - if [ -d "$dir" ]; then - branch=$(basename "$dir") - echo "Configurando location para: /$branch/" - - # Agregar location para esta rama - cat >> /etc/nginx/conf.d/default.conf << EOF_LOCATION - # Configuración para /$branch/ (SPA) - location ~ ^/$branch(/|$) { - alias /usr/share/nginx/html/$branch/; - index index.html index.htm; - - # Intentar servir el archivo, si no existe servir index.html de esa rama - try_files \$uri \$uri/ /$branch/index.html =404; - } - -EOF_LOCATION - fi -done - -# Cerrar el bloque server y agregar configuración para la raíz (rama principal) -cat >> /etc/nginx/conf.d/default.conf << 'EOF_FOOTER' - # Configuración para la raíz (rama principal) - # Esto debe ir al final para que tenga menor prioridad - location / { - try_files $uri $uri/ /index.html =404; - } -} -EOF_FOOTER - -echo "" -echo "=== Configuración de nginx generada ===" -cat /etc/nginx/conf.d/default.conf -echo "========================================" - -echo "" -echo "=== Estructura de directorios ===" -ls -la /usr/share/nginx/html/ -echo "========================================" - -# Limpiar los archivos comprimidos para reducir el tamaño de la imagen -rm -f /tmp/*.tar.gz diff --git a/nginx.conf b/nginx.conf index 5ee22c58..d49c521d 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,10 +1,8 @@ -# Configuración para subdominios -# Captura cualquier subdominio y lo mapea a su directorio correspondiente server { listen 80; - server_name ~^(?[^.]+)\.docs1\.dev\.solopcloud\.com$; + server_name localhost; - root /usr/share/nginx/html/$branch; + root /usr/share/nginx/html; index index.html index.htm; # Logs @@ -23,24 +21,27 @@ server { access_log off; } - # Configuración para archivos estáticos comunes + # Configuración para archivos estáticos comunes (debe ir primero para mayor prioridad) location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|json|xml|txt|pdf|map)$ { expires 1y; add_header Cache-Control "public, immutable"; try_files $uri =404; } - # Configuración SPA: redirigir todo a index.html + # Configuración para cada subdirectorio (otras ramas/tags) + # Cada directorio se trata como una SPA independiente + location ~ ^/([^/]+)(/|$) { + set $branch_dir $1; + + # Primero intentar servir el archivo exacto + # Si no existe, intentar como directorio con index.html + # Si tampoco existe, servir el index.html del directorio raíz de esa rama (para SPAs) + try_files $uri $uri/ /$branch_dir/index.html =404; + } + + # Configuración para la raíz (rama principal) + # Esto debe ir al final para que tenga menor prioridad location / { try_files $uri $uri/ /index.html =404; } } - -# Configuración para el dominio principal (sin subdominio) -server { - listen 80 default_server; - server_name docs1.dev.solopcloud.com; - - # Redirigir a un subdominio por defecto (por ejemplo, la rama main) - return 301 http://main.docs1.dev.solopcloud.com$request_uri; -} From 8acd9b1c10d66c1cd3e435af62f88363df131603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Fri, 7 Nov 2025 16:58:52 -0300 Subject: [PATCH 42/45] Fix Action --- .github/workflows/build-and-package.yml | 8 ++++-- Dockerfile | 4 +-- configure-base-paths.sh | 38 ++++++++++++++++++++----- nginx.conf | 8 +++--- src/.vuepress/config.ts | 21 ++++++++++++++ 5 files changed, 64 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index afc0e1d8..84cf84f4 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -7,6 +7,10 @@ on: tags: - '*' +env: + # Rama principal del proyecto - modificar aquí para cambiar la rama por defecto + DEFAULT_BRANCH: feature-1636-pack-doc + jobs: build-and-package: runs-on: ubuntu-latest @@ -39,6 +43,8 @@ jobs: - name: Build Blog env: NODE_OPTIONS: --max_old_space_size=8192 + BRANCH_NAME: ${{ github.ref_name }} + DEFAULT_BRANCH: ${{ env.DEFAULT_BRANCH }} run: pnpm run build:webpack - name: Compress Build Output (tar.gz) @@ -82,8 +88,6 @@ jobs: needs: - check-digitalocean-secrets if: needs.check-digitalocean-secrets.outputs.is_have_secrets == 'true' - env: - DEFAULT_BRANCH: feature-1636-pack-doc-2 steps: - name: Checkout Repository diff --git a/Dockerfile b/Dockerfile index d1012d5c..014af459 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ # Usar la última versión estable de nginx FROM nginx:stable -# Argumentos para configuración -ARG DEFAULT_BRANCH=main +# Argumentos para configuración (debe ser pasado desde el build) +ARG DEFAULT_BRANCH # Convertir los ARGs en variables de entorno ENV DEFAULT_BRANCH=${DEFAULT_BRANCH} diff --git a/configure-base-paths.sh b/configure-base-paths.sh index 2924803e..2f66d005 100644 --- a/configure-base-paths.sh +++ b/configure-base-paths.sh @@ -1,13 +1,18 @@ #!/bin/bash set -e -DEFAULT_BRANCH="${DEFAULT_BRANCH:-main}" +# La variable DEFAULT_BRANCH debe ser pasada como variable de entorno +if [ -z "$DEFAULT_BRANCH" ]; then + echo "ERROR: DEFAULT_BRANCH no está definida" + exit 1 +fi echo "=== Configurando base paths para cada directorio ===" echo "DEFAULT_BRANCH: ${DEFAULT_BRANCH}" echo "" # Procesar cada archivo tar.gz descargado +# TODAS las ramas van a subdirectorios (incluyendo la principal) for file in /tmp/*.tar.gz; do if [ -f "$file" ]; then filename=$(basename "$file") @@ -17,14 +22,13 @@ for file in /tmp/*.tar.gz; do echo "Procesando: $branch" - # Determinar el base path para esta rama + # TODAS las ramas van a su propio subdirectorio + BASE_PATH="/${branch}/" + TARGET_DIR="/usr/share/nginx/html/${branch}" + if [ "$branch" = "${DEFAULT_BRANCH}" ]; then - BASE_PATH="/" - TARGET_DIR="/usr/share/nginx/html" - echo " -> Base path: / (raíz - rama principal)" + echo " -> Base path: ${BASE_PATH} (rama principal)" else - BASE_PATH="/${branch}/" - TARGET_DIR="/usr/share/nginx/html/${branch}" echo " -> Base path: ${BASE_PATH}" fi @@ -53,6 +57,26 @@ for file in /tmp/*.tar.gz; do fi done +# Crear redirección 301 en la raíz hacia la rama principal +echo "=== Creando redirección en raíz ===" +cat > /usr/share/nginx/html/index.html << EOF + + + + + + + Redireccionando... + + +

Redireccionando a /${DEFAULT_BRANCH}/...

+ + + +EOF +echo " -> Redirección creada: / → /${DEFAULT_BRANCH}/" + +echo "" echo "=== Estructura de directorios final ===" ls -la /usr/share/nginx/html/ echo "" diff --git a/nginx.conf b/nginx.conf index d49c521d..540ea057 100644 --- a/nginx.conf +++ b/nginx.conf @@ -28,7 +28,7 @@ server { try_files $uri =404; } - # Configuración para cada subdirectorio (otras ramas/tags) + # Configuración para cada subdirectorio (ramas/tags) # Cada directorio se trata como una SPA independiente location ~ ^/([^/]+)(/|$) { set $branch_dir $1; @@ -39,9 +39,9 @@ server { try_files $uri $uri/ /$branch_dir/index.html =404; } - # Configuración para la raíz (rama principal) + # Configuración para la raíz - página de redirección # Esto debe ir al final para que tenga menor prioridad - location / { - try_files $uri $uri/ /index.html =404; + location = / { + try_files /index.html =404; } } diff --git a/src/.vuepress/config.ts b/src/.vuepress/config.ts index 87f0d276..b18a2ed9 100644 --- a/src/.vuepress/config.ts +++ b/src/.vuepress/config.ts @@ -3,7 +3,28 @@ import theme from "./theme"; import { searchPlugin } from '@vuepress/plugin-search' import { path } from "@vuepress/utils"; +// Configuración dinámica del base path según la rama +// TODAS las ramas usan su propio base path (incluyendo la rama principal) +// La variable BRANCH_NAME debe ser pasada desde el build +const branchName = process.env.BRANCH_NAME; + +if (!branchName) { + throw new Error('ERROR: BRANCH_NAME no está definida. Debe ser pasada desde el build.'); +} + +// Siempre usar /nombre-de-la-rama/ (sin excepciones) +const basePath = `/${branchName}/`; + +console.log('========================================'); +console.log('VuePress Base Path Configuration'); +console.log('========================================'); +console.log('BRANCH_NAME:', branchName); +console.log('Base Path:', basePath); +console.log('========================================'); + export default defineUserConfig({ + base: basePath, + alias: { "@Releases": path.resolve(__dirname, "components/Releases.vue"), }, From 903b385e3abadb6aaf53160ae1a0e9aad30f7fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Fri, 7 Nov 2025 17:33:29 -0300 Subject: [PATCH 43/45] Fix Action --- .github/workflows/build-and-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-package.yml b/.github/workflows/build-and-package.yml index 84cf84f4..fb098c88 100644 --- a/.github/workflows/build-and-package.yml +++ b/.github/workflows/build-and-package.yml @@ -9,7 +9,7 @@ on: env: # Rama principal del proyecto - modificar aquí para cambiar la rama por defecto - DEFAULT_BRANCH: feature-1636-pack-doc + DEFAULT_BRANCH: v1636-2 jobs: build-and-package: From f92da2d08c019bdaca11cd4ccc5eab3e8edcf06c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Fri, 7 Nov 2025 18:19:11 -0300 Subject: [PATCH 44/45] Fix Action --- src/docs/test-page/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/docs/test-page/README.md b/src/docs/test-page/README.md index 12863513..be036d04 100644 --- a/src/docs/test-page/README.md +++ b/src/docs/test-page/README.md @@ -1,4 +1,7 @@ ### Página de Prueba - Nuevo Sitio -Página de prueba para nuevo sitio \ No newline at end of file +Página de prueba para nuevo sitio + +Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. + From 7e99d2c21f9721c1e0625c5bb696460d980ec2f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Capecce?= Date: Fri, 7 Nov 2025 19:06:53 -0300 Subject: [PATCH 45/45] Fix Action --- src/docs/test-page/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/docs/test-page/README.md b/src/docs/test-page/README.md index be036d04..ff8e72a2 100644 --- a/src/docs/test-page/README.md +++ b/src/docs/test-page/README.md @@ -1,7 +1,5 @@ ### Página de Prueba - Nuevo Sitio -Página de prueba para nuevo sitio - -Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. +Lorem Ipsum is simply dummy text of the printing and typesetting industry.