begin docker setup
Gitea/subman-nextjs/pipeline/head This commit is unstable Details

This commit is contained in:
andrzej 2024-10-01 14:56:25 +02:00
parent 78b599bfcf
commit 9a3cd629fd
6 changed files with 90 additions and 10 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
.log
node_modules
.git
.next

73
Dockerfile Normal file
View File

@ -0,0 +1,73 @@
FROM node:20-alpine AS base
### Dependencies ###
FROM base AS deps
RUN apk add --no-cache libc6-compat git
# Setup pnpm environment
ENV NPM_HOME="/npm"
ENV PATH="$NPM_HOME:$PATH"
RUN corepack enable
RUN corepack prepare npm@latest --activate
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install --production
# Builder
FROM base AS builder
RUN corepack enable
RUN corepack prepare npm@latest --activate
COPY prisma prisma
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN [ "npx", "prisma", generate ]
RUN npm run build
### Production image runner ###
FROM base AS runner
# Set NODE_ENV to production
ENV NODE_ENV production
# Disable Next.js telemetry
# Learn more here: https://nextjs.org/telemetry
ENV NEXT_TELEMETRY_DISABLED 1
# Set correct permissions for nextjs user and don't run as root
RUN addgroup nodejs
RUN adduser -SDH nextjs
RUN mkdir .next
RUN chown nextjs:nodejs .next
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
USER nextjs
# Exposed port (for orchestrators and dynamic reverse proxies)
EXPOSE 3000
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "wget", "-q0", "http://localhost:3000/health" ]
# Run the nextjs app
CMD ["node", "server.js"]

8
ecosystem.config.js Normal file
View File

@ -0,0 +1,8 @@
module.exports = {
apps: [
{
name: "subman",
script: "npm run next start",
},
],
};

View File

@ -4,6 +4,7 @@ const nextConfig = {
config.externals = [...config.externals, "bcrypt"];
return config;
},
output: "standalone",
};
export default nextConfig;

12
package-lock.json generated
View File

@ -32,6 +32,7 @@
"lucide-react": "^0.394.0",
"next": "^14.2.13",
"next-themes": "^0.3.0",
"prisma": "^5.15.0",
"react": "^18",
"react-day-picker": "^8.10.1",
"react-dom": "^18",
@ -49,7 +50,6 @@
"autoprefixer": "^10.4.19",
"eslint-config-next": "14.2.3",
"postcss": "^8.4.38",
"prisma": "^5.15.0",
"tailwindcss": "^3.4.4",
"typescript": "^5"
}
@ -429,7 +429,6 @@
"version": "5.16.0",
"resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.16.0.tgz",
"integrity": "sha512-OGvi/GvLX3XwTWQ+k/57kLyHGidQ8rC8zB+Zq9nEE7gegjazyzgLYN9qzfdcCfyI8ilc6IMxOyX4sspwkv98hg==",
"devOptional": true,
"hasInstallScript": true,
"dependencies": {
"@prisma/debug": "5.16.0",
@ -441,20 +440,17 @@
"node_modules/@prisma/engines-version": {
"version": "5.16.0-24.34ace0eb2704183d2c05b60b52fba5c43c13f303",
"resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.16.0-24.34ace0eb2704183d2c05b60b52fba5c43c13f303.tgz",
"integrity": "sha512-HkT2WbfmFZ9WUPyuJHhkiADxazHg8Y4gByrTSVeb3OikP6tjQ7txtSUGu9OBOBH0C13dPKN2qqH12xKtHu/Hiw==",
"devOptional": true
"integrity": "sha512-HkT2WbfmFZ9WUPyuJHhkiADxazHg8Y4gByrTSVeb3OikP6tjQ7txtSUGu9OBOBH0C13dPKN2qqH12xKtHu/Hiw=="
},
"node_modules/@prisma/engines/node_modules/@prisma/debug": {
"version": "5.16.0",
"resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-5.16.0.tgz",
"integrity": "sha512-pfdOGxMShqZKkNNskYB0yXICsqL6rOkQUKNktouUZ9Y9ASd5736+ae2fpzif7onwJiIyEpu/yvOO3rFUbliKTA==",
"devOptional": true
"integrity": "sha512-pfdOGxMShqZKkNNskYB0yXICsqL6rOkQUKNktouUZ9Y9ASd5736+ae2fpzif7onwJiIyEpu/yvOO3rFUbliKTA=="
},
"node_modules/@prisma/engines/node_modules/@prisma/fetch-engine": {
"version": "5.16.0",
"resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.16.0.tgz",
"integrity": "sha512-8C8y6J9eWRl+R/aO3vQ2HlmM9IbjAmrZaaEAdC0OJfG3CHvbTOcL7VRY6CEUKo8RwZ8bdATOePaSMS634fHWgw==",
"devOptional": true,
"dependencies": {
"@prisma/debug": "5.16.0",
"@prisma/engines-version": "5.16.0-24.34ace0eb2704183d2c05b60b52fba5c43c13f303",
@ -465,7 +461,6 @@
"version": "5.16.0",
"resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.16.0.tgz",
"integrity": "sha512-ynp2jAYfYdd7OObX+uWaFRpvhPVmpF0nsRMhbrWdVVUj39q3Zr8dGz5WDj2g+BTUE++u1T1Am3RyM3PBQdDZXA==",
"devOptional": true,
"dependencies": {
"@prisma/debug": "5.16.0"
}
@ -7660,7 +7655,6 @@
"version": "5.16.0",
"resolved": "https://registry.npmjs.org/prisma/-/prisma-5.16.0.tgz",
"integrity": "sha512-T1ZWJT/vgzp3rtRmd1iCSnPPsgOItXnnny+/cfpHraowiBEvUMD2pEI6yEOL6CP2EelTmq4wKDbXbYucy4Fd+A==",
"devOptional": true,
"hasInstallScript": true,
"dependencies": {
"@prisma/engines": "5.16.0"

View File

@ -39,6 +39,7 @@
"react-day-picker": "^8.10.1",
"react-dom": "^18",
"react-hook-form": "^7.51.5",
"prisma": "^5.15.0",
"recharts": "^2.12.7",
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7",
@ -52,7 +53,6 @@
"autoprefixer": "^10.4.19",
"eslint-config-next": "14.2.3",
"postcss": "^8.4.38",
"prisma": "^5.15.0",
"tailwindcss": "^3.4.4",
"typescript": "^5"
},