diff --git a/.dockerignore b/.dockerignore index 7dce7fb..8f12398 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,4 +9,5 @@ README.md .git db internal -shared \ No newline at end of file +shared +dist \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6000d6b..dbb07ed 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,5 @@ kube-config.config_clusteradmin kube-config.config_old kube-config.config_restricted internal -shared \ No newline at end of file +shared +dist \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 4faf1f2..f7a6ddb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,6 +24,7 @@ COPY . . RUN yarn run prisma-generate-build RUN yarn run build +RUN rm -rf ./next/standalone # Production image, copy all the files and run next FROM base AS runner @@ -38,15 +39,14 @@ RUN adduser --system --uid 1001 nextjs COPY --from=builder /app/public ./public -# Set the correct permission for prerender cache -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/prisma ./prisma -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/.next ./.next +COPY --from=builder --chown=nextjs:nodejs /app/dist ./dist +COPY --from=builder --chown=nextjs:nodejs /app/dist ./dist +COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json +COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules USER nextjs @@ -54,4 +54,4 @@ ENV PORT=3000 # server.js is created by next build from the standalone output # https://nextjs.org/docs/pages/api-reference/next-config-js/output -CMD HOSTNAME="0.0.0.0" node server.js \ No newline at end of file +CMD HOSTNAME="0.0.0.0" npm run start-prod \ No newline at end of file diff --git a/bun.lockb b/bun.lockb index 96c0fbd..fed80d1 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index c739c72..7d3d2b9 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,9 @@ "scripts": { "dev": "next dev", "dev-live": "bun src/server.ts", - "build": "next build", + "build": "next build && tsc --project tsconfig.server.json", "start": "next start", + "start-prod": "cross-env NODE_ENV=production node dist/server.js", "prisma-generate": "bunx prisma generate && bun ./fix-wrong-zod-imports.js", "prisma-generate-build": "npx prisma generate && node ./fix-wrong-zod-imports.js", "prisma-migrate": "bunx prisma migrate dev --name migration", @@ -38,6 +39,7 @@ "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", "cmdk": "1.0.0", + "cross-env": "^7.0.3", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "lucide-react": "^0.453.0", diff --git a/setup.sh b/setup.sh index 7ab3832..18b4af8 100644 --- a/setup.sh +++ b/setup.sh @@ -105,6 +105,65 @@ rm cluster-issuer.yaml sudo kubectl get nodes +# deploy QuickStack +cat < quick-stack.yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: quickstack-internal-pvc + namespace: quickstack +spec: + accessModes: + - ReadWriteOnce + storageClassName: longhorn + resources: + requests: + storage: 1Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: quickstack + namespace: quickstack +spec: + replicas: 1 + selector: + matchLabels: + app: quickstack + template: + metadata: + labels: + app: quickstack + spec: + strategy: + type: Recreate + containers: + - name: quickstack-container + image: quickstack/quickstack:latest + imagePullPolicy: "Always" + volumeMounts: + - name: quickstack-internal-pvc + mountPath: /mnt/internal + volumes: + - name: quickstack-internal-pvc + persistentVolumeClaim: + claimName: quickstack-internal-pvc +--- +apiVersion: v1 +kind: Service +metadata: + name: quickstack-svc + namespace: quickstack +spec: + selector: + app: quickstack + ports: + - nodePort: 3000 + protocol: TCP + port: 3000 + targetPort: 3000 +EOF + # evaluate url to add node to cluster joinTokenForOtherNodes=$(sudo cat /var/lib/rancher/k3s/server/node-token) echo "To add a worker node to the cluster, run the following command on the worker node:" diff --git a/tsconfig.server.json b/tsconfig.server.json new file mode 100644 index 0000000..a23db08 --- /dev/null +++ b/tsconfig.server.json @@ -0,0 +1,17 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "commonjs", + "outDir": "dist", + "lib": [ + "ES2023" + ], + "target": "ES2023", + "isolatedModules": false, + "noEmit": false + }, + "include": [ + "src/server.ts" + ] +} \ No newline at end of file