From f0ed200577891caf0ca630b67df6f1d8287efe73 Mon Sep 17 00:00:00 2001 From: josedario87 Date: Mon, 4 Aug 2025 13:51:09 -0600 Subject: [PATCH] Add Docker deployment configuration and CI/CD pipeline --- .dockerignore | 32 ++++++++++++++++++++++++++ .gitea/workflows/build.yml | 46 ++++++++++++++++++++++++++++++++++++++ .gitignore | 16 ++++++++++++- Dockerfile | 33 +++++++++++++++++++++++++++ docker-compose.yml | 29 ++++++++++++++++++++++++ 5 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 .gitea/workflows/build.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f801bba --- /dev/null +++ b/.dockerignore @@ -0,0 +1,32 @@ +node_modules +npm-debug.log +.git +.gitignore +README.md +.env* +.nyc_output +coverage +.vscode +.idea +*.swp +*.swo +*~ +.DS_Store +Thumbs.db +music/ +*.mp3 +*.wav +*.flac +*.m4a +*.ogg +*.aac +.output +.nuxt +.cache +dist +logs +*.log +.tmp +.parcel-cache +docker-compose*.yml +Dockerfile* \ No newline at end of file diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..cf7993a --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,46 @@ +name: build-and-deploy + +on: + push: + branches: [ main ] + +jobs: +#───────────────── build & push ───────────────── + build: + runs-on: docker + env: + REG: gitea.nucleoriofrio.com/nucleo000 + steps: + - uses: actions/checkout@v3 + - uses: docker/setup-buildx-action@v2 + - uses: docker/login-action@v2 + with: + registry: gitea.nucleoriofrio.com + username: nucleo000 + password: 7bc7b2fcd283bd6a251bef3ede368b7f897c919d + + - name: Build+push repodructor + run: | + docker build -t $REG/repodructor:${{ github.sha }} -t $REG/repodructor:latest . + docker push $REG/repodructor:${{ github.sha }} + docker push $REG/repodructor:latest + +#───────────────── deploy ───────────────── + deploy: + needs: build + runs-on: docker + env: + REG: gitea.nucleoriofrio.com/nucleo000 + steps: + - uses: actions/checkout@v3 + - name: Login to registry + run: docker login gitea.nucleoriofrio.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 repodructor down + + - name: Update stack + run: docker compose --project-name repodructor up -d --remove-orphans --wait \ No newline at end of file diff --git a/.gitignore b/.gitignore index ad5bc82..a7114c1 100644 --- a/.gitignore +++ b/.gitignore @@ -87,4 +87,18 @@ music/ # PWA files sw.js -workbox-*.js \ No newline at end of file +workbox-*.js + +# Docker and deployment +.env* +docker-compose.override.yml +.dockerignore + +# SSL certificates +*.pem +*.crt +*.key + +# Production secrets +secrets/ +credentials/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8fab06d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +# Build stage +FROM node:18-alpine AS builder + +WORKDIR /app + +# Copy package files +COPY package*.json ./ + +# Install dependencies +RUN npm ci --only=production + +# Copy source code +COPY . . + +# Build the application +RUN npm run build + +# Production stage +FROM node:18-alpine AS production + +WORKDIR /app + +# Copy built application from builder stage +COPY --from=builder /app/.output ./ + +# Create music directory for volume mounting +RUN mkdir -p /app/public/music + +# Expose port +EXPOSE 3000 + +# Start the application +CMD ["node", "server/index.mjs"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a1b110d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,29 @@ +version: '3.8' + +services: + repodructor: + image: gitea.nucleoriofrio.com/nucleo000/repodructor:latest + container_name: repodructor + restart: unless-stopped + volumes: + - type: volume + source: nas-music + target: /app/public/music + read_only: true + environment: + - NODE_ENV=production + - NUXT_HOST=0.0.0.0 + - NUXT_PORT=3000 + networks: + - principal + +volumes: + nas-music: + driver_opts: + type: cifs + o: username=nucleo000,password=${NAS_PASSWORD},addr=memoria.interno.com + device: //memoria.interno.com/homes/nucleo000/musik + +networks: + principal: + external: true \ No newline at end of file