Add Docker support and Gitea Actions workflow for container builds
Some checks failed
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 4m55s

This commit is contained in:
2026-03-25 17:07:17 +00:00
parent 7c5f2f30f0
commit ff5ecd82ca
4 changed files with 217 additions and 0 deletions

78
Dockerfile Normal file
View File

@@ -0,0 +1,78 @@
# Mana Loop - Next.js Game Docker Image
# Multi-stage build for optimized production image
# Stage 1: Dependencies
FROM node:20-alpine AS deps
WORKDIR /app
# Install dependencies for native modules
RUN apk add --no-cache libc6-compat
# Copy package files
COPY package.json bun.lockb* ./
COPY prisma ./prisma/
# Install bun for faster installs
RUN npm install -g bun
# Install dependencies
RUN bun install --frozen-lockfile --production=false
# Stage 2: Builder
FROM node:20-alpine AS builder
WORKDIR /app
# Copy dependencies from deps stage
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Install bun for build
RUN npm install -g bun
# Set environment variables for build
ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production
# Generate Prisma client
RUN bun run db:generate
# Build the application
RUN bun run build
# Stage 3: Runner
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Create non-root user for security
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Copy necessary files from builder
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
# Set correct ownership
RUN chown -R nextjs:nodejs /app
# Switch to non-root user
USER nextjs
# Expose port
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000 || exit 1
# Start the server
CMD ["node", "server.js"]