mirror of
https://gitlab.w-hs.de/an14051/backerup-website.git
synced 2026-07-27 17:35:29 +00:00
Initial Commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
# ── Stage 1: deps ─────────────────────────────────────────────────────────────
|
||||
FROM oven/bun:1 AS deps
|
||||
WORKDIR /app
|
||||
|
||||
COPY frontend/package.json frontend/bun.lock* ./
|
||||
RUN bun install --frozen-lockfile
|
||||
|
||||
# ── Stage 2: builder ──────────────────────────────────────────────────────────
|
||||
FROM oven/bun:1 AS builder
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY frontend/ .
|
||||
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
RUN bun run build
|
||||
|
||||
# ── Stage 3: runner ───────────────────────────────────────────────────────────
|
||||
FROM oven/bun:1-slim AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
# Dedicated non-root user
|
||||
RUN addgroup --system --gid 1001 nodejs && \
|
||||
adduser --system --uid 1001 nextjs
|
||||
|
||||
# Next.js standalone output
|
||||
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
|
||||
|
||||
# Writable data directory for file uploads
|
||||
RUN mkdir -p /app/data/uploads && chown -R nextjs:nodejs /app/data
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME=0.0.0.0
|
||||
|
||||
CMD ["bun", "server.js"]
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# build.sh — Build the backerup-website Docker image.
|
||||
# Usage: ./docker/build.sh [TAG]
|
||||
# TAG defaults to "backerup-website:latest"
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
TAG="${1:-backerup-website:latest}"
|
||||
|
||||
echo "==> Building image: $TAG"
|
||||
docker build \
|
||||
--file "$REPO_ROOT/docker/Dockerfile" \
|
||||
--tag "$TAG" \
|
||||
"$REPO_ROOT"
|
||||
|
||||
echo "==> Done. Image tagged as '$TAG'."
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
# deploy.sh — Build the image and start (or restart) the local stack.
|
||||
# Usage: ./docker/deploy.sh [TAG]
|
||||
# TAG defaults to "backerup-website:latest"
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
TAG="${1:-backerup-website:latest}"
|
||||
|
||||
# 1. Build
|
||||
"$SCRIPT_DIR/build.sh" "$TAG"
|
||||
|
||||
# 2. Export the image tag so docker compose picks it up if you override it
|
||||
export BACKERUP_IMAGE="$TAG"
|
||||
|
||||
# 3. Bring the stack up (recreate on image change)
|
||||
echo "==> Starting stack via docker compose…"
|
||||
docker compose \
|
||||
--file "$SCRIPT_DIR/docker-compose.yml" \
|
||||
up --detach --pull never --remove-orphans
|
||||
|
||||
echo "==> Backerup website is running at http://localhost:3000"
|
||||
@@ -0,0 +1,16 @@
|
||||
services:
|
||||
backerup-website:
|
||||
image: backerup-website:latest
|
||||
container_name: backerup-website
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- backerup_data:/app/data
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
volumes:
|
||||
backerup_data:
|
||||
driver: local
|
||||
Reference in New Issue
Block a user