feat: Add Docker infrastructure and Gitea CI/CD pipeline

- Add Dockerfiles for server, client, and admin services
- Create docker-compose.yml for orchestration
- Add Gitea Actions workflow for automated build/deploy
- Configure conditional builds based on directory changes
- Use gitea.interno.com registry for image storage

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-07-05 14:19:19 -06:00
parent eb6d19906b
commit 580099bf59
5 changed files with 229 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
name: build-and-deploy
on:
push:
branches: [ master ]
jobs:
#───────────────── filtra qué dirs cambiaron ─────────────────
filter:
runs-on: docker
outputs:
server: ${{ steps.paths.outputs.server }}
client: ${{ steps.paths.outputs.client }}
admin: ${{ steps.paths.outputs.admin }}
steps:
- uses: actions/checkout@v3
- id: paths
uses: dorny/paths-filter@v3
with:
filters: |
server: "server/**"
client: "client/**"
admin: "admin/**"
#───────────────── build & push ─────────────────
build:
needs: filter
runs-on: docker
env:
REG: gitea.interno.com/nucleo000
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: gitea.interno.com
username: nucleo000 # ⬅ ponelo en secrets
password: 7bc7b2fcd283bd6a251bef3ede368b7f897c919d # ⬅ idem
- name: Build+push server
if: needs.filter.outputs.server == 'true'
run: |
docker build -f server/Dockerfile -t $REG/snatchgame-server:${{ github.sha }} -t $REG/snatchgame-server:latest server
docker push $REG/snatchgame-server:${{ github.sha }}
docker push $REG/snatchgame-server:latest
- name: Build+push client
if: needs.filter.outputs.client == 'true'
run: |
docker build -f client/Dockerfile -t $REG/snatchgame-client:${{ github.sha }} -t $REG/snatchgame-client:latest client
docker push $REG/snatchgame-client:${{ github.sha }}
docker push $REG/snatchgame-client:latest
- name: Build+push admin
if: needs.filter.outputs.admin == 'true'
run: |
docker build -f admin/Dockerfile -t $REG/snatchgame-admin:${{ github.sha }} -t $REG/snatchgame-admin:latest admin
docker push $REG/snatchgame-admin:${{ github.sha }}
docker push $REG/snatchgame-admin:latest
#───────────────── deploy ─────────────────
deploy:
needs: build
runs-on: docker
env:
REG: gitea.interno.com/nucleo000
steps:
- uses: actions/checkout@v3
- name: Login to registry
run: docker login gitea.interno.com -u nucleo000 -p 7bc7b2fcd283bd6a251bef3ede368b7f897c919d
- name: Pull fresh images used in compose
run: docker compose pull
- name: Clean up stack
run: docker compose --project-name snatchgame down
- name: Update stack
run: docker compose --project-name snatchgame up -d --remove-orphans --wait

27
admin/Dockerfile Normal file
View File

@@ -0,0 +1,27 @@
# Admin Dockerfile - Vue 3 Admin Dashboard
FROM node:18-alpine
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy source code
COPY . .
# Build Vue application
RUN npm run build
# Expose port
EXPOSE 3001
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3001/health || exit 1
# Start admin server
CMD ["npm", "start"]

27
client/Dockerfile Normal file
View File

@@ -0,0 +1,27 @@
# Client Dockerfile - Vue 3 Client UI
FROM node:18-alpine
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy source code
COPY . .
# Build Vue application
RUN npm run build
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
# Start client server
CMD ["npm", "start"]

69
docker-compose.yml Normal file
View File

@@ -0,0 +1,69 @@
version: '3.8'
services:
# Servidor Colyseus
snatchgame-server:
image: gitea.interno.com/nucleo000/snatchgame-server:latest
container_name: snatchgame-server
ports:
- "2567:2567"
environment:
- NODE_ENV=production
- PORT=2567
networks:
- snatchgame-network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:2567/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Cliente Vue UI
snatchgame-client:
image: gitea.interno.com/nucleo000/snatchgame-client:latest
container_name: snatchgame-client
ports:
- "3000:3000"
environment:
- NODE_ENV=production
- PORT=3000
- VITE_SERVER_URL=http://snatchgame-server:2567
depends_on:
- snatchgame-server
networks:
- snatchgame-network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Admin Dashboard
snatchgame-admin:
image: gitea.interno.com/nucleo000/snatchgame-admin:latest
container_name: snatchgame-admin
ports:
- "3001:3001"
environment:
- NODE_ENV=production
- PORT=3001
- VITE_SERVER_URL=http://snatchgame-server:2567
depends_on:
- snatchgame-server
networks:
- snatchgame-network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3001/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
snatchgame-network:
driver: bridge

27
server/Dockerfile Normal file
View File

@@ -0,0 +1,27 @@
# Server Dockerfile - Colyseus Server
FROM node:18-alpine
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci --only=production
# Copy source code
COPY . .
# Build TypeScript
RUN npm run build
# Expose port
EXPOSE 2567
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:2567/health || exit 1
# Start server
CMD ["npm", "start"]