docker configuration

This commit is contained in:
tcsenpai 2025-02-14 18:18:40 +01:00
parent 251fbdee7d
commit 9f84921d7d
5 changed files with 2619 additions and 9 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
node_modules
.next
.git
.env*

36
Dockerfile Normal file
View File

@ -0,0 +1,36 @@
# Base node image
FROM node:20-alpine AS base
WORKDIR /app
# Dependencies stage
FROM base AS deps
COPY package.json package-lock.json ./
RUN npm ci
# Builder stage
FROM base AS builder
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# Runner stage
FROM base AS runner
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED 1
# Create non-root user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Copy necessary files and set permissions
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
USER nextjs
EXPOSE 3000
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"
CMD ["node", "server.js"]

25
docker-compose.yml Normal file
View File

@ -0,0 +1,25 @@
version: "3.8"
services:
web:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
environment:
- NODE_ENV=production
restart: unless-stopped
healthcheck:
test:
[
"CMD",
"wget",
"--no-verbose",
"--tries=1",
"--spider",
"http://localhost:3000",
]
interval: 30s
timeout: 10s
retries: 3

View File

@ -1,6 +1,6 @@
let userConfig = undefined
let userConfig = undefined;
try {
userConfig = await import('./v0-user-next.config')
userConfig = await import("./v0-user-next.config");
} catch (e) {
// ignore error
}
@ -21,28 +21,29 @@ const nextConfig = {
parallelServerBuildTraces: true,
parallelServerCompiles: true,
},
}
output: "standalone",
};
mergeConfig(nextConfig, userConfig)
mergeConfig(nextConfig, userConfig);
function mergeConfig(nextConfig, userConfig) {
if (!userConfig) {
return
return;
}
for (const key in userConfig) {
if (
typeof nextConfig[key] === 'object' &&
typeof nextConfig[key] === "object" &&
!Array.isArray(nextConfig[key])
) {
nextConfig[key] = {
...nextConfig[key],
...userConfig[key],
}
};
} else {
nextConfig[key] = userConfig[key]
nextConfig[key] = userConfig[key];
}
}
}
export default nextConfig
export default nextConfig;

2544
yarn.lock Normal file

File diff suppressed because it is too large Load Diff