This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
name: Deploy Next.js via Docker
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: docker:latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
run: |
|
||||
apk add --no-cache curl unzip
|
||||
curl -L -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||
"http://172.17.0.1:3000/api/v1/repos/${{ github.repository }}/archive/main.zip" -o repo.zip
|
||||
unzip repo.zip
|
||||
mv TimeInPie/* . 2>/dev/null || mv timeinpie/* . 2>/dev/null || mv */* . 2>/dev/null
|
||||
rm repo.zip
|
||||
|
||||
- name: Update Docker container
|
||||
run: |
|
||||
echo "Building new Next.js Docker image..."
|
||||
docker build -t timeinpie-app .
|
||||
|
||||
echo "Stopping old container if running..."
|
||||
docker stop timeinpie-container || true
|
||||
docker rm timeinpie-container || true
|
||||
|
||||
echo "Starting new container..."
|
||||
docker run -d \
|
||||
--name timeinpie-container \
|
||||
-p 8443:3000 \
|
||||
--restart always \
|
||||
timeinpie-app
|
||||
|
||||
- name: Create release in Gitea
|
||||
run: |
|
||||
apk add --no-cache jq curl
|
||||
VERSION=$(jq -r '.version' package.json)
|
||||
echo "Current version: v$VERSION"
|
||||
|
||||
# Shell-kompatible Prüfung (funktioniert zuverlässig in Alpine/sh)
|
||||
case "$VERSION" in
|
||||
0.*)
|
||||
IS_PRERELEASE="true"
|
||||
echo "Version starts with 0. Setting prerelease to true."
|
||||
;;
|
||||
*)
|
||||
IS_PRERELEASE="false"
|
||||
echo "Setting prerelease to false."
|
||||
;;
|
||||
esac
|
||||
|
||||
# Prüfen, ob das Release bereits existiert
|
||||
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||
"http://172.17.0.1:3000/api/v1/repos/${{ github.repository }}/releases/tags/v$VERSION")
|
||||
|
||||
if [ "$HTTP_STATUS" -eq 404 ]; then
|
||||
echo "Creating new release v$VERSION..."
|
||||
# Gitea erstellt bei diesem Call automatisch auch den Tag v$VERSION auf 'main'
|
||||
curl -X POST \
|
||||
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"tag_name\": \"v$VERSION\",
|
||||
\"target_commitish\": \"main\",
|
||||
\"name\": \"Release v$VERSION\",
|
||||
\"body\": \"Automated release for version v$VERSION\",
|
||||
\"draft\": false,
|
||||
\"prerelease\": $IS_PRERELEASE
|
||||
}" \
|
||||
"http://172.17.0.1:3000/api/v1/repos/${{ github.repository }}/releases"
|
||||
else
|
||||
echo "Release v$VERSION already exists. Skipping creation."
|
||||
fi
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
FROM docker.io/library/node:22-alpine AS base
|
||||
ENV PNPM_HOME="/pnpm"
|
||||
ENV PATH="$PNPM_HOME:$PATH"
|
||||
RUN corepack enable
|
||||
|
||||
FROM base AS deps
|
||||
WORKDIR /app
|
||||
COPY package.json pnpm-lock.yaml* pnpm-workspace.yaml* ./
|
||||
|
||||
# System-Pakete für better-sqlite3 installieren
|
||||
RUN apk add --no-cache python3 make g++
|
||||
|
||||
# Installation mit deiner funktionierenden Workspace-Konfiguration
|
||||
RUN pnpm i --frozen-lockfile
|
||||
|
||||
FROM base AS builder
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
RUN pnpm run build
|
||||
|
||||
FROM base AS runner
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Kopiere die Standalone-Dateien (existieren jetzt dank der Next-Config)
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
COPY --from=builder /app/public ./public
|
||||
|
||||
EXPOSE 3000
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
/* config options here */
|
||||
output: 'standalone',
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
|
||||
Reference in New Issue
Block a user