-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Huge upgrade to next.js with prisma ORM based on postgres
- Loading branch information
Showing
101 changed files
with
11,746 additions
and
18,367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# being used by deploy.sh on ./deploy.sh local start | ||
|
||
DATABASE_PASSWORD="setpasswordhere" | ||
DATABASE_USERNAME="2a5-development" | ||
DATABASE_NAME="2a5-development" | ||
DATABASE_PORT=5432 | ||
DATABASE_HOST="2a5-db-development" | ||
DATABASE_URL="postgresql://${DATABASE_USERNAME}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}" | ||
DOCKER_WEB_HOSTNAME="2a5-web-development" | ||
DOCKER_WEB_TARGET="runnerDevelopment" | ||
DOCKER_WEB_IMAGE="2a5-web-development" | ||
DOCKER_WEB_PORT=3000 | ||
DOCKER_WEB_CONTAINERNAME="2a5-web-development" | ||
DOCKER_DB_CONTAINERNAME="2a5-db-development" | ||
DOCKER_DB_VOLUMENAME="2a5-db-data-development" | ||
LINK_PROTOCOL="http" | ||
LINK_HOSTNAME="localhost" | ||
LINK_PORT=3000 | ||
ADMIN_PORT=8001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# being used by nextjs on `npm run dev` | ||
|
||
DATABASE_PASSWORD="setpasswordhere" | ||
DATABASE_USERNAME="2a5-development" | ||
DATABASE_NAME="2a5-development" | ||
DATABASE_PORT=5432 | ||
DATABASE_HOST="localhost" | ||
DATABASE_URL="postgresql://${DATABASE_USERNAME}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}" | ||
LINK_PROTOCOL="http" | ||
LINK_HOSTNAME="localhost" | ||
LINK_PORT=3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
DATABASE_PASSWORD="setpasswordhere" | ||
DATABASE_USERNAME="2a5-prod" | ||
DATABASE_NAME="2a5-prod" | ||
DATABASE_PORT=5433 | ||
DATABASE_HOST="2a5-db-prod" | ||
DATABASE_URL="postgresql://${DATABASE_USERNAME}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}" | ||
DOCKER_WEB_HOSTNAME="2a5-web-prod" | ||
DOCKER_WEB_TARGET="runnerBuild" | ||
DOCKER_WEB_IMAGE="2a5-web-prod" | ||
DOCKER_WEB_PORT=8082 | ||
DOCKER_WEB_CONTAINERNAME="2a5-web-prod" | ||
DOCKER_DB_CONTAINERNAME="2a5-db-prod" | ||
DOCKER_DB_VOLUMENAME="2a5-db-data-prod" | ||
LINK_PROTOCOL="https" | ||
LINK_HOSTNAME="2a5.de" | ||
# LINK_PORT="" # is not set here so that short links do not have a port defined - but could do so if needed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
DATABASE_PASSWORD="setpasswordhere" | ||
DATABASE_USERNAME="2a5-test" | ||
DATABASE_NAME="2a5-test" | ||
DATABASE_PORT=5432 | ||
DATABASE_HOST="2a5-db-test" | ||
DATABASE_URL="postgresql://${DATABASE_USERNAME}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}" | ||
DOCKER_WEB_HOSTNAME="2a5-web-test" | ||
DOCKER_WEB_TARGET="runnerBuild" | ||
DOCKER_WEB_IMAGE="2a5-web-test" | ||
DOCKER_WEB_PORT=8081 | ||
DOCKER_WEB_CONTAINERNAME="2a5-web-test" | ||
DOCKER_DB_CONTAINERNAME="2a5-db-test" | ||
DOCKER_DB_VOLUMENAME="2a5-db-data-test" | ||
LINK_PROTOCOL="https" | ||
LINK_HOSTNAME="test.2a5.de" | ||
# LINK_PORT="" # is not set here so that short links do not have a port defined - but could do so if needed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "next/core-web-vitals", | ||
"rules": { | ||
"semi": ["error", "always"], | ||
"quotes": ["error", "double"], | ||
"indent": ["error", 4] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,47 @@ | ||
.vscode/ | ||
|
||
deploy.tar | ||
admin/build | ||
admin/node_modules | ||
|
||
config/process.local.env | ||
config/process.test.env | ||
config/process.prod.env | ||
prisma-client/ | ||
|
||
ssl/ | ||
migration/backup.json | ||
|
||
backend/ssl | ||
backend/config | ||
cypress/videos | ||
cypress/screenshots | ||
|
||
frontend/app/node_modules | ||
frontend/app/build | ||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
frontend/server/build | ||
frontend/server/config | ||
frontend/server/ssl | ||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# local env files | ||
.env*.local | ||
**/.env | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
FROM node:18-alpine AS base | ||
|
||
###################################################################################### | ||
# 1. Install dependencies only when needed | ||
FROM base AS deps | ||
|
||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. | ||
RUN apk add --no-cache libc6-compat | ||
|
||
WORKDIR /app | ||
|
||
# Install dependencies based on the preferred package manager | ||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ | ||
RUN \ | ||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ | ||
elif [ -f package-lock.json ]; then npm ci; \ | ||
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \ | ||
else echo "Lockfile not found." && exit 1; \ | ||
fi | ||
|
||
###################################################################################### | ||
# 2. Rebuild the source code only when needed | ||
FROM base AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY components ./components | ||
COPY lib ./lib | ||
COPY pages ./pages | ||
COPY prisma ./prisma | ||
COPY public ./public | ||
COPY styles ./styles | ||
COPY .eslintrc.json next.config.js package-lock.json package.json postcss.config.js tailwind.config.js tsconfig.json ./ | ||
COPY .env.development.docker.local ./.env | ||
RUN npm run prismagenerate | ||
RUN npm run build | ||
|
||
###################################################################################### | ||
# 3. Production image, copy all the files and run next | ||
FROM base AS runnerDevelopment | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV=production | ||
|
||
RUN addgroup -g 1001 -S nodejs | ||
RUN adduser -S nextjs -u 1001 | ||
|
||
COPY --from=builder /app/public ./public | ||
COPY --from=builder /app/prisma-client ../prisma-client | ||
|
||
# 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 | ||
|
||
USER nextjs | ||
|
||
EXPOSE 3000 | ||
|
||
ENV PORT 3000 | ||
|
||
CMD ["node", "server.js"] | ||
|
||
###################################################################################### | ||
FROM base AS runnerBuild | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV=production | ||
|
||
RUN addgroup -g 1001 -S nodejs | ||
RUN adduser -S nextjs -u 1001 | ||
|
||
COPY build ./ | ||
|
||
USER nextjs | ||
|
||
EXPOSE 3000 | ||
|
||
ENV PORT 3000 | ||
|
||
CMD ["node", "server.js"] | ||
|
||
###################################################################################### | ||
FROM base AS depsAdmin | ||
RUN apk add --no-cache libc6-compat | ||
WORKDIR /app | ||
|
||
# Install dependencies based on the preferred package manager | ||
COPY admin/package.json admin/yarn.lock* admin/package-lock.json* admin/pnpm-lock.yaml* ./ | ||
RUN \ | ||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ | ||
elif [ -f package-lock.json ]; then npm ci; \ | ||
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \ | ||
else echo "Lockfile not found." && exit 1; \ | ||
fi | ||
|
||
###################################################################################### | ||
# 2. Rebuild the source code only when needed | ||
FROM base AS builderAdmin | ||
WORKDIR /app | ||
COPY --from=depsAdmin /app/node_modules ./admin/node_modules | ||
COPY admin/public ./admin/public | ||
COPY admin/views ./admin/views | ||
COPY prisma ./admin/prisma | ||
COPY .eslintrc.json admin/package-lock.json admin/package.json admin/tsconfig.json admin/index.ts ./admin/ | ||
COPY .env.development.docker.local ./admin/.env | ||
WORKDIR /app/admin | ||
RUN npm run prismagenerate | ||
RUN cp -R prisma-client/ ../ | ||
RUN npm run build | ||
|
||
###################################################################################### | ||
# 3. Production image, copy all the files and run next | ||
FROM base AS runnerDevelopmentAdmin | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV=production | ||
|
||
RUN addgroup -g 1001 -S adminjs | ||
RUN adduser -S adminjs -u 1001 | ||
|
||
COPY --from=depsAdmin /app/node_modules ./admin/node_modules | ||
COPY --from=builderAdmin /app/admin/public ./admin/public | ||
COPY --from=builderAdmin /app/admin/views ./admin/views | ||
COPY --from=builderAdmin /app/prisma-client ./prisma-client | ||
COPY --from=builderAdmin /app/admin/index.js ./admin/index.js | ||
COPY .env.development.docker.local ./admin/.env | ||
COPY .env.development.docker.local ./.env | ||
|
||
USER adminjs | ||
|
||
EXPOSE 8001 | ||
|
||
ENV PORT 8001 | ||
WORKDIR /app/admin | ||
CMD ["node", "index.js"] |
Oops, something went wrong.