Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
73ceb3b
Se agrega nuevo action para realizar pack de documentación
rcapecce Oct 16, 2025
bda9934
Fix action
rcapecce Oct 16, 2025
e32d015
Fix action
rcapecce Oct 16, 2025
e975067
Fix action
rcapecce Oct 16, 2025
fc61f82
Fix action
rcapecce Oct 16, 2025
04a1770
Fix action
rcapecce Oct 16, 2025
3c9fa41
Set to store in DigitalOcean
rcapecce Oct 16, 2025
12e757a
Fix action
rcapecce Oct 16, 2025
5c49e6b
Fix Action
rcapecce Oct 16, 2025
c611f96
Fix Action
rcapecce Oct 16, 2025
1a894c0
Fix action
rcapecce Oct 16, 2025
ddcf527
Test override
rcapecce Oct 16, 2025
4a59242
Se agrega Docker Repo DitgitalOcean
rcapecce Oct 17, 2025
8489f28
Fix action
rcapecce Oct 17, 2025
e37ccd3
Corrección de login en s3
rcapecce Oct 30, 2025
cf9e522
Fix Action
rcapecce Oct 30, 2025
6c35476
Fix Action
rcapecce Oct 30, 2025
42ed2aa
Fix Action
rcapecce Nov 6, 2025
c249885
Fix Action
rcapecce Nov 6, 2025
b99f886
Fix Action
rcapecce Nov 6, 2025
ecc1711
Fix Action
rcapecce Nov 6, 2025
6f4c71a
Fix Action
rcapecce Nov 6, 2025
7f6efe1
Fix Action
rcapecce Nov 6, 2025
d44dc78
Fix Action
rcapecce Nov 6, 2025
dbf4c03
Fix Action
rcapecce Nov 6, 2025
a7d7cf7
Fix Action
rcapecce Nov 6, 2025
037801e
Fix Action
rcapecce Nov 6, 2025
309d28c
Fix Action
rcapecce Nov 6, 2025
765221a
Fix Action
rcapecce Nov 6, 2025
90a6346
Fix Action
rcapecce Nov 6, 2025
dbeeec8
Fix Action
rcapecce Nov 7, 2025
84beeea
Fix Action
rcapecce Nov 7, 2025
79b94dd
Fix Action
rcapecce Nov 7, 2025
2881f2d
Fix Action
rcapecce Nov 7, 2025
0895434
Fix Action
rcapecce Nov 7, 2025
233a7d2
Fix Action
rcapecce Nov 7, 2025
2b005ac
Fix Action
rcapecce Nov 7, 2025
b49f3cf
Fix Action
rcapecce Nov 7, 2025
97fa24f
Fix Action
rcapecce Nov 7, 2025
578eaa2
Fix Action
rcapecce Nov 7, 2025
ff90365
Fix Action
rcapecce Nov 7, 2025
8acd9b1
Fix Action
rcapecce Nov 7, 2025
903b385
Fix Action
rcapecce Nov 7, 2025
f92da2d
Fix Action
rcapecce Nov 7, 2025
7e99d2c
Fix Action
rcapecce Nov 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions .github/workflows/build-and-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Deploy blog

on:
push:
branches:
- feature*
tags:
- '*'

env:
# Rama principal del proyecto - modificar aquí para cambiar la rama por defecto
DEFAULT_BRANCH: v1636-2

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
BRANCH_NAME: ${{ github.ref_name }}
DEFAULT_BRANCH: ${{ env.DEFAULT_BRANCH }}
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
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: Create download directory
run: mkdir -p s3-downloads

- name: Download 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/ \
s3-downloads/ \
--endpoint-url https://nyc3.digitaloceanspaces.com \
--no-progress

- name: show-directory
run: ls -alh s3-downloads

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to DigitalOcean Container Registry
uses: docker/login-action@v3
with:
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: ${{ vars.DIGITALOCEAN_REGISTRY }}/${{ vars.DOCKER_REPO_DOCS_SP }}:main
file: ./Dockerfile
build-args: |
DEFAULT_BRANCH=${{ env.DEFAULT_BRANCH }}
67 changes: 0 additions & 67 deletions .github/workflows/test.yml

This file was deleted.

31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Usar la última versión estable de nginx
FROM nginx:stable

# 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}

# 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 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/configure-base-paths.sh && \
/tmp/configure-base-paths.sh && \
rm /tmp/configure-base-paths.sh

# Exponer el puerto 80
EXPOSE 80

# El comando por defecto de nginx ya está definido en la imagen base
# nginx -g "daemon off;"
87 changes: 87 additions & 0 deletions configure-base-paths.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash
set -e

# 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")
dirname=$(basename "$file" .tar.gz)
# Eliminar el prefijo "docs-sp-" si existe
branch=${dirname#docs-sp-}

echo "Procesando: $branch"

# TODAS las ramas van a su propio subdirectorio
BASE_PATH="/${branch}/"
TARGET_DIR="/usr/share/nginx/html/${branch}"

if [ "$branch" = "${DEFAULT_BRANCH}" ]; then
echo " -> Base path: ${BASE_PATH} (rama principal)"
else
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 <base> tag
if grep -q "<base" "$html_file"; then
# Reemplazar el base tag existente
sed -i "s|<base href=\"[^\"]*\"|<base href=\"${BASE_PATH}\"|g" "$html_file"
else
# Agregar base tag después de <head>
sed -i "s|<head>|<head>\n <base href=\"${BASE_PATH}\">|" "$html_file"
fi
done

echo " -> ✓ Completado"
echo ""
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
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0;url=/${DEFAULT_BRANCH}/">
<link rel="canonical" href="/${DEFAULT_BRANCH}/" />
<title>Redireccionando...</title>
</head>
<body>
<p>Redireccionando a <a href="/${DEFAULT_BRANCH}/">/${DEFAULT_BRANCH}/</a>...</p>
<script>window.location.replace("/${DEFAULT_BRANCH}/");</script>
</body>
</html>
EOF
echo " -> Redirección creada: / → /${DEFAULT_BRANCH}/"

echo ""
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 ==="
7 changes: 7 additions & 0 deletions docker-compose/.env
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading