mirror of
https://github.com/tcsenpai/emoji-encoder.git
synced 2025-06-04 09:40:05 +00:00
docker configuration
This commit is contained in:
parent
251fbdee7d
commit
9f84921d7d
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
node_modules
|
||||||
|
.next
|
||||||
|
.git
|
||||||
|
.env*
|
36
Dockerfile
Normal file
36
Dockerfile
Normal 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
25
docker-compose.yml
Normal 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
|
@ -1,6 +1,6 @@
|
|||||||
let userConfig = undefined
|
let userConfig = undefined;
|
||||||
try {
|
try {
|
||||||
userConfig = await import('./v0-user-next.config')
|
userConfig = await import("./v0-user-next.config");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// ignore error
|
// ignore error
|
||||||
}
|
}
|
||||||
@ -21,28 +21,29 @@ const nextConfig = {
|
|||||||
parallelServerBuildTraces: true,
|
parallelServerBuildTraces: true,
|
||||||
parallelServerCompiles: true,
|
parallelServerCompiles: true,
|
||||||
},
|
},
|
||||||
}
|
output: "standalone",
|
||||||
|
};
|
||||||
|
|
||||||
mergeConfig(nextConfig, userConfig)
|
mergeConfig(nextConfig, userConfig);
|
||||||
|
|
||||||
function mergeConfig(nextConfig, userConfig) {
|
function mergeConfig(nextConfig, userConfig) {
|
||||||
if (!userConfig) {
|
if (!userConfig) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const key in userConfig) {
|
for (const key in userConfig) {
|
||||||
if (
|
if (
|
||||||
typeof nextConfig[key] === 'object' &&
|
typeof nextConfig[key] === "object" &&
|
||||||
!Array.isArray(nextConfig[key])
|
!Array.isArray(nextConfig[key])
|
||||||
) {
|
) {
|
||||||
nextConfig[key] = {
|
nextConfig[key] = {
|
||||||
...nextConfig[key],
|
...nextConfig[key],
|
||||||
...userConfig[key],
|
...userConfig[key],
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
nextConfig[key] = userConfig[key]
|
nextConfig[key] = userConfig[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default nextConfig
|
export default nextConfig;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user