Add Dockerfile and CI/CD pipeline
Some checks failed
Build and Deploy / build (push) Failing after 56s
Build and Deploy / deploy (push) Has been skipped

This commit is contained in:
Lorentz 2026-02-15 22:42:41 +00:00
parent 36c157893e
commit 50833b778a
4 changed files with 83 additions and 17 deletions

View file

@ -0,0 +1,55 @@
name: Build and Deploy
on:
push:
branches:
- main
- development
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Forgejo Registry
uses: docker/login-action@v3
with:
registry: forgejo.wulfconsulting.cloud
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Determine tag
id: tag
run: |
if [ "${{ github.ref_name }}" = "main" ]; then
echo "tag=latest" >> $GITHUB_OUTPUT
else
echo "tag=dev" >> $GITHUB_OUTPUT
fi
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: forgejo.wulfconsulting.cloud/lorentz/quest-vorteq:${{ steps.tag.outputs.tag }}
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy to server
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_SSH_KEY }}
script: |
cd /opt/stacks/vorteq
docker compose pull app-prod app-dev
docker compose up -d app-prod app-dev

View file

@ -1,16 +0,0 @@
name: Test CI
on:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Hello
run: echo "Forgejo Actions is working!"

28
Dockerfile Normal file
View file

@ -0,0 +1,28 @@
FROM node:22-alpine AS base
# Install dependencies
FROM base AS deps
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci
# Build the application
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# Production image
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
CMD ["node", "server.js"]

View file

@ -1,4 +1,3 @@
version: '3.8'
services:
# Traefik Reverse Proxy