ci: add automated SSH deployment workflow
Some checks failed
Deploy Frontend to VPS / deploy (push) Failing after 1s
Some checks failed
Deploy Frontend to VPS / deploy (push) Failing after 1s
This commit is contained in:
parent
cd13f0d93f
commit
28e734897c
3 changed files with 71 additions and 2 deletions
32
.forgejo/workflows/deploy.yml
Normal file
32
.forgejo/workflows/deploy.yml
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
name: Deploy Frontend to VPS
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Trigger Build & Deploy via SSH
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.VPS_HOST }}
|
||||||
|
username: ${{ secrets.VPS_USER }}
|
||||||
|
key: ${{ secrets.VPS_SSH_KEY }}
|
||||||
|
port: ${{ secrets.VPS_PORT }}
|
||||||
|
script: |
|
||||||
|
echo "🚀 Deployment gestartet..."
|
||||||
|
cd /opt/containers/frontend
|
||||||
|
|
||||||
|
echo "📥 Hole neuesten Code..."
|
||||||
|
git pull origin main
|
||||||
|
|
||||||
|
echo "🏗️ Baue Docker Image neu..."
|
||||||
|
docker compose up -d --build
|
||||||
|
|
||||||
|
echo "🧹 Alte Docker Images aufräumen..."
|
||||||
|
docker image prune -f
|
||||||
|
|
||||||
|
echo "✅ Deployment erfolgreich abgeschlossen!"
|
||||||
37
Dockerfile
Normal file
37
Dockerfile
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
# 1. Dependencies installieren
|
||||||
|
FROM node:20-alpine AS deps
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
# 2. Anwendung bauen
|
||||||
|
FROM node:20-alpine AS builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# 3. Production Image ausführen (Node.js Server)
|
||||||
|
FROM node:20-alpine AS runner
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV PORT=3000
|
||||||
|
|
||||||
|
# Systemnutzer anlegen für mehr Sicherheit
|
||||||
|
RUN addgroup --system --gid 1001 nodejs
|
||||||
|
RUN adduser --system --uid 1001 nextjs
|
||||||
|
|
||||||
|
# Public & Standalone Build kopieren
|
||||||
|
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
|
||||||
|
|
||||||
|
# Ordner für Analytics-Daten anlegen und Schreibrechte vergeben
|
||||||
|
RUN mkdir -p /app/data && chown -R nextjs:nodejs /app/data
|
||||||
|
|
||||||
|
USER nextjs
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
CMD ["node", "server.js"]
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
output: "export",
|
output: "standalone",
|
||||||
trailingSlash: true,
|
trailingSlash: false,
|
||||||
images: {
|
images: {
|
||||||
unoptimized: true,
|
unoptimized: true,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue