mirror of
https://github.com/R0m1k3/Menu.git
synced 2026-10-11 17:28:28 +02:00
feat: add Docker support with multi-stage build, compose configuration, and standalone output mode
This commit is contained in:
1 parent
b73aa8616b
commit
6c0aef1d88
5 files changed
+108
-1
No files matched your search
@@ -0,0 +1,13 @@
|
|||||||
|
node_modules
|
||||||
|
.next
|
||||||
|
.git
|
||||||
|
.env
|
||||||
|
*.db
|
||||||
|
*.db-journal
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
.dockerignore
|
||||||
|
Dockerfile
|
||||||
|
docker-compose.yml
|
||||||
|
README.md
|
||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
# Stage 1: Build
|
||||||
|
FROM node:20-bookworm-slim AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install build dependencies for better-sqlite3 and bcrypt
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
python3 \
|
||||||
|
make \
|
||||||
|
g++ \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY package*.json ./
|
||||||
|
COPY prisma ./prisma/
|
||||||
|
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Generate Prisma Client (crucial for standalone)
|
||||||
|
RUN npx prisma generate
|
||||||
|
|
||||||
|
# Build Next.js app
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Stage 2: Runner
|
||||||
|
FROM node:20-bookworm-slim AS runner
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
|
|
||||||
|
# Install runtime dependencies for SQLite
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
openssl \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Copy standalone build and static files
|
||||||
|
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
|
||||||
|
|
||||||
|
# Expose port
|
||||||
|
EXPOSE 3214
|
||||||
|
|
||||||
|
# Set up entrypoint script
|
||||||
|
COPY entrypoint.sh ./
|
||||||
|
RUN chmod +x entrypoint.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["./entrypoint.sh"]
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
services:
|
||||||
|
menu-app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: menu-professional
|
||||||
|
ports:
|
||||||
|
- "3214:3214"
|
||||||
|
volumes:
|
||||||
|
- ./.env:/app/.env
|
||||||
|
- menu_db:/app/prisma
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=production
|
||||||
|
- DATABASE_URL=file:/app/prisma/dev.db
|
||||||
|
- PORT=3214
|
||||||
|
networks:
|
||||||
|
- nginx_default
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
networks:
|
||||||
|
nginx_default:
|
||||||
|
external: true
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
menu_db:
|
||||||
|
driver: local
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Exit immediately if a command exits with a non-zero status
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Starting Menu Professional..."
|
||||||
|
|
||||||
|
# Run database synchronization
|
||||||
|
# Note: In a production environment with persistent data,
|
||||||
|
# 'prisma db push' ensures the schema matches the code.
|
||||||
|
echo "Synchronizing database schema..."
|
||||||
|
npx prisma db push --accept-data-loss || echo "Database sync failed, but proceeding..."
|
||||||
|
|
||||||
|
# Start the application using node as Next.js is in standalone mode
|
||||||
|
echo "Launching server..."
|
||||||
|
exec node server.js
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
/* config options here */
|
output: 'standalone',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
Reference in new issue
Block a user