Compare commits

...

4 Commits

Author SHA1 Message Date
andrzej d667b45701 build out to docker tarball
Gitea/subman-nextjs/pipeline/head There was a failure building this commit Details
2024-10-01 22:48:58 +02:00
andrzej 136ee9ef6c fix dockerfile
Gitea/subman-nextjs/pipeline/head There was a failure building this commit Details
2024-10-01 16:57:06 +02:00
andrzej 6b3d43f040 transition to pnpm
Gitea/subman-nextjs/pipeline/head There was a failure building this commit Details
2024-10-01 15:04:42 +02:00
andrzej 9a3cd629fd begin docker setup
Gitea/subman-nextjs/pipeline/head This commit is unstable Details
2024-10-01 14:56:25 +02:00
9 changed files with 5188 additions and 14 deletions

4
.dockerignore Normal file
View File

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

74
Dockerfile Normal file
View File

@ -0,0 +1,74 @@
FROM node:20-alpine AS base
### Dependencies ###
FROM base AS deps
RUN apk add --no-cache libc6-compat git
# Setup pnpm environment
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
RUN corepack prepare pnpm@latest --activate
## WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --prefer-frozen-lockfile
# Builder
FROM base AS builder
RUN corepack enable
RUN corepack prepare pnpm@latest --activate
COPY prisma prisma
WORKDIR /app
COPY --from=deps /node_modules ./node_modules
COPY . .
RUN pnpm prisma db push
RUN pnpm 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
COPY --from=builder --chown=nextjs:node:js /app/prisma ./prisma
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"]

7
Jenkinsfile vendored
View File

@ -7,13 +7,14 @@ agent any
stages{ stages{
stage('build'){ stage('build'){
steps{ steps{
sh 'npm install' sh 'pnpm install'
sh 'npm run build' sh 'docker build -t subman .'
sh 'docker buildx build --output type=tar . | gzip > subman.tar.gz'
} }
} }
stage('deploy'){ stage('deploy'){
steps{ steps{
sshPublisher(publishers: [sshPublisherDesc(configName: 'Demos', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: 'ssh-uploads/subman', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '**')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)]) sshPublisher(publishers: [sshPublisherDesc(configName: 'Demos', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: 'ssh-uploads/subman', remoteDirectorySDF: false, removePrefix: '', sourceFiles: 'subman.tar.gz')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
} }
} }
} }

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"]; config.externals = [...config.externals, "bcrypt"];
return config; return config;
}, },
output: "standalone",
}; };
export default nextConfig; export default nextConfig;

12
package-lock.json generated
View File

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

View File

@ -4,6 +4,7 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"preinstall": "npx only-allow pnpm",
"dev": "next dev", "dev": "next dev",
"build": "next build", "build": "next build",
"start": "next start", "start": "next start",
@ -39,6 +40,7 @@
"react-day-picker": "^8.10.1", "react-day-picker": "^8.10.1",
"react-dom": "^18", "react-dom": "^18",
"react-hook-form": "^7.51.5", "react-hook-form": "^7.51.5",
"prisma": "^5.15.0",
"recharts": "^2.12.7", "recharts": "^2.12.7",
"tailwind-merge": "^2.3.0", "tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7", "tailwindcss-animate": "^1.0.7",
@ -52,12 +54,12 @@
"autoprefixer": "^10.4.19", "autoprefixer": "^10.4.19",
"eslint-config-next": "14.2.3", "eslint-config-next": "14.2.3",
"postcss": "^8.4.38", "postcss": "^8.4.38",
"prisma": "^5.15.0",
"tailwindcss": "^3.4.4", "tailwindcss": "^3.4.4",
"typescript": "^5" "typescript": "^5"
}, },
"overrides": { "overrides": {
"@radix-ui/react-dismissable-layer": "^1.0.5", "@radix-ui/react-dismissable-layer": "^1.0.5",
"@radix-ui/react-focus-scope": "^1.0.4" "@radix-ui/react-focus-scope": "^1.0.4"
} },
"packageManager": "pnpm@9.11.0+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b"
} }

5083
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

7
pnpm-workspace.yaml Normal file
View File

@ -0,0 +1,7 @@
packages:
# include packages in subfolders (e.g. apps/ and packages/)
- "apps/**"
- 'packages/**'
# if required, exclude some directories
- '!**/test/**'