diff --git a/.dockerignore b/.dockerignore index e4a85ab..fffcfb8 100644 --- a/.dockerignore +++ b/.dockerignore @@ -25,4 +25,3 @@ frontend/node_modules #**/**/*out* **/**/*reports* **/**/*.nyc_output* - diff --git a/.gitattributes b/.gitattributes index 0d9e767..c11135f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,2 @@ # Auto line endings -* text=auto eol=lf \ No newline at end of file +* text=auto eol=lf diff --git a/.gitignore b/.gitignore index 5fc74e9..62d4d64 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ /cypress-coverage /reports - **/node_modules/ npmlist.json @@ -43,8 +42,6 @@ sentry.server.config.js public/sitemap*.xml public/robots.txt - - # production /build diff --git a/.husky/.gitignore b/.husky/.gitignore index c9cdc63..31354ec 100644 --- a/.husky/.gitignore +++ b/.husky/.gitignore @@ -1 +1 @@ -_ \ No newline at end of file +_ diff --git a/.husky/commit-msg b/.husky/commit-msg index 2672bfc..61681a8 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -pnpm exec commitlint --edit $1 \ No newline at end of file +pnpm exec commitlint --edit $1 diff --git a/.husky/pre-commit b/.husky/pre-commit index 055a5b8..f28061d 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -3,7 +3,7 @@ # Disable concurent to run `check-types` after ESLint in lint-staged pnpm exec lint-staged --concurrent false -# Sync possible .env changes to .env.example -# pnpm exec run-s env +# Sync possible .env changes to .env.example +# pnpm exec run-s env # Sync env file with types diff --git a/.prettierignore b/.prettierignore index 0b5389e..4e653fc 100644 --- a/.prettierignore +++ b/.prettierignore @@ -29,4 +29,4 @@ frontend/reports/ .nyc_output/ frontend/.nyc_output/ .pnpm-store/ -backend/prisma/json-schema/ \ No newline at end of file +backend/prisma/json-schema/ diff --git a/Dockerfile b/Dockerfile index 8cfb613..b1ba399 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,8 +17,6 @@ RUN adduser --disabled-password --gecos "" nodejs && usermod -a -G nodejs nodejs RUN adduser nodejs sudo RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers - - # set right (secure) folder permissions RUN mkdir -p /home/nodejs/app/node_modules RUN mkdir -p /home/nodejs/app/frontend/node_modules @@ -37,14 +35,13 @@ RUN sudo apt install nodejs # TODO: Make this use the project's pnpm version, not the latest version otherwise this could break the project down the road RUN sudo npm i -g pnpm concurrently -# COPY --chown=nodejs:nodejs . . +# COPY --chown=nodejs:nodejs . . # ENV NODE_ENV=production COPY --chown=nodejs:nodejs scripts/* ./ COPY --chown=nodejs:nodejs package.json pnpm-lock.yaml pnpm-workspace.yaml ./ - # Non built files first COPY --chown=nodejs:nodejs frontend/*.json ./frontend/ COPY --chown=nodejs:nodejs frontend/*.config.js ./frontend/ @@ -73,10 +70,8 @@ COPY --chown=nodejs:nodejs frontend/.next/static /home/nodejs/app/frontend/.next COPY --chown=nodejs:nodejs scripts /home/nodejs/app/scripts COPY --chown=nodejs:nodejs ecosystem.config.js /home/nodejs/app/ecosystem.config.js - RUN node dockerBuildAndInstall.mjs - # Production image, copy all the files and run next # FROM timbru31/node-alpine-git:hydrogen AS runner # WORKDIR /home/nodejs/app @@ -90,7 +85,6 @@ COPY --chown=nodejs:nodejs frontend ./frontend # COPY --chown=nodejs:nodejs backend/dist/* ./ COPY --chown=nodejs:nodejs backend ./backend - # COPY --chown=nodejs:nodejs healthCheck.js . RUN --mount=type=cache,id=pnpm,target=/home/nodejs/.pnpm-store CYPRESS_INSTALL_BINARY=0 pnpm install --frozen-lockfile --prefer-offline @@ -102,7 +96,6 @@ RUN pnpm build RUN pnpm prune --config.ignore-scripts=true --prod RUN cd backend && pnpm prune --config.ignore-scripts=true --prod - FROM ubuntu AS runner RUN adduser --disabled-password --gecos "" nodejs && usermod -a -G nodejs nodejs RUN apt update && apt install -y curl @@ -132,8 +125,6 @@ RUN rm -rf node_modules RUN cd backend && npx pnpm install -D prisma --ignore-scripts RUN HUSKY=0 npx pnpm install --prod - - #RUN npm i -g next # Work in progress @@ -149,7 +140,6 @@ ENV BACKEND_PORT 8000 # FROM timbru31/node-alpine-git:hydrogen AS builder # WORKDIR /home/nodejs/app - # COPY --from=deps --chown=nodejs:nodejs . . # COPY --from=deps /app/node_modules ./node_modules # COPY . . @@ -164,8 +154,6 @@ ENV BACKEND_PORT 8000 # IMPORTANT: NOT BUILDING, USING PREBUILT - - # COPY --chown=nodejs:nodejs .next/static* ./.next/static # COPY --chown=nodejs:nodejs --from=builder . . @@ -191,9 +179,7 @@ ENV BACKEND_PORT 8000 # COPY --chown=nodejs:nodejs backend/*.json ./ - - -# # This dockerfile expects the project to already be built locally to make the Dockerfile do less and make it smaller +# # This dockerfile expects the project to already be built locally to make the Dockerfile do less and make it smaller # COPY --chown=nodejs:nodejs dist ./ # # Repetitive, ik. For compatability reasons # COPY --chown=nodejs:nodejs dist ./dist diff --git a/backend/.dockerignore b/backend/.dockerignore index 118cfb8..270eb28 100644 --- a/backend/.dockerignore +++ b/backend/.dockerignore @@ -33,7 +33,6 @@ backupPostgres .nyc_output /cypress - _old # /*.min.js* @@ -64,4 +63,4 @@ Dockerfile Dockerfile*.* Jenkinsfile Jenkinsfile*.* -/jenkins \ No newline at end of file +/jenkins diff --git a/backend/.eslintignore b/backend/.eslintignore index 90a1eee..ad18c99 100644 --- a/backend/.eslintignore +++ b/backend/.eslintignore @@ -14,4 +14,4 @@ prisma/seed.ts **/out/ **/build/ **/jest-coverage/ -**/pnpm-lock.yaml \ No newline at end of file +**/pnpm-lock.yaml diff --git a/backend/.gitignore b/backend/.gitignore index 5226ea5..90ea407 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -34,7 +34,7 @@ node_modules jspm_packages coverage jest-coverage -secret-key +secret-key # secret key for jwt # Optional npm cache directory @@ -64,7 +64,6 @@ profile* *clinic* *flamegraph* - dev.db PostgresData @@ -72,4 +71,4 @@ PostgresData2 dockerApp DockerRedisCache backupPostgres -.nyc_output \ No newline at end of file +.nyc_output diff --git a/backend/Dockerfile b/backend/Dockerfile index 068889c..8640060 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -12,7 +12,7 @@ RUN apk add libc6-compat # set a non privileged user to use when running this image RUN addgroup -S nodejs && adduser -S nodejs -G nodejs -SHELL ["bash", "-c"] +SHELL ["bash", "-c"] # set right (secure) folder permissions RUN mkdir -p /home/nodejs/app/node_modules && chown -R nodejs:nodejs /home/nodejs/app @@ -23,17 +23,15 @@ RUN mkdir -p /home/nodejs/.pnpm-store && chown -R nodejs:nodejs /home/nodejs/.pn RUN mkdir -p /home/nodejs/.pnpm-global && chown -R nodejs:nodejs /home/nodejs/.pnpm-global RUN pnpm config set store-dir /home/nodejs/.pnpm-store - USER nodejs WORKDIR /home/nodejs/app -SHELL ["bash", "-c"] - +SHELL ["bash", "-c"] # set default node env # to be able to run tests (for example in CI), do not set production as environment ENV NODE_ENV=production -ENV PNPM_HOME=/home/nodejs/.local/share/pnpm -ENV PATH=$PATH:$PNPM_HOME +ENV PNPM_HOME=/home/nodejs/.local/share/pnpm +ENV PATH=$PATH:$PNPM_HOME COPY --chown=nodejs:nodejs pnpm-workspace.yaml* ./ @@ -41,8 +39,7 @@ COPY --chown=nodejs:nodejs pnpm-workspace.yaml* ./ COPY --chown=nodejs:nodejs package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* .pnpmfile.cjs* ./ RUN pnpm install --prod - -# This dockerfile expects the project to already be built locally to make the Dockerfile do less and make it smaller +# This dockerfile expects the project to already be built locally to make the Dockerfile do less and make it smaller COPY --chown=nodejs:nodejs dist ./ # Repetitive, ik. For compatability reasons COPY --chown=nodejs:nodejs dist ./dist diff --git a/backend/prisma/.gitignore b/backend/prisma/.gitignore index 8507dbe..2015164 100644 --- a/backend/prisma/.gitignore +++ b/backend/prisma/.gitignore @@ -1,3 +1,3 @@ generated migrations -json-schema \ No newline at end of file +json-schema diff --git a/frontend/.eslintignore b/frontend/.eslintignore index 34cddd7..10f57d2 100644 --- a/frontend/.eslintignore +++ b/frontend/.eslintignore @@ -3,7 +3,7 @@ out public jest-coverage coverage -.next +.next .swc **/dist/ **/lib/ diff --git a/frontend/.gitignore b/frontend/.gitignore index cced815..27c6aa3 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -41,8 +41,6 @@ sentry.server.config.js public/sitemap*.xml public/robots.txt - - # production /build @@ -67,4 +65,4 @@ local .vercel # Sentry -.sentryclirc \ No newline at end of file +.sentryclirc diff --git a/frontend/Dockerfile b/frontend/Dockerfile index ecb03a6..eef9f29 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -3,7 +3,7 @@ # Goal: Create NextJS docker image that uses multiple cores and should be production ready -FROM timbru31/node-alpine-git:hydrogen AS deps +FROM timbru31/node-alpine-git:hydrogen AS deps RUN apk add --no-cache bash # 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 @@ -12,7 +12,7 @@ RUN apk add --no-cache libc6-compat # set a non privileged user to use when running this image RUN addgroup -S nodejs && adduser -S nodejs -G nodejs -SHELL ["bash", "-c"] +SHELL ["bash", "-c"] # set right (secure) folder permissions RUN mkdir -p /home/nodejs/app/node_modules && chown -R nodejs:nodejs /home/nodejs/app @@ -24,11 +24,9 @@ RUN mkdir -p /home/nodejs/.pnpm-global && chown -R nodejs:nodejs /home/nodejs/.p RUN pnpm config set store-dir /home/nodejs/.pnpm-store - USER nodejs WORKDIR /home/nodejs/app - ENV PNPM_HOME=/home/nodejs/.local/share/pnpm ENV PATH=$PATH:$PNPM_HOME @@ -36,8 +34,6 @@ ENV PATH=$PATH:$PNPM_HOME COPY --chown=nodejs:nodejs package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ RUN HUSKY=0 CYPRESS_INSTALL_BINARY=0 pnpm install - - # Work in progress # RUN SHELL=bash pnpm setup # RUN pnpm add -g pm2 @@ -46,7 +42,6 @@ RUN HUSKY=0 CYPRESS_INSTALL_BINARY=0 pnpm install FROM timbru31/node-alpine-git:hydrogen AS builder WORKDIR /home/nodejs/app - # COPY --from=deps --chown=nodejs:nodejs . . COPY --from=deps /home/nodejs/app/node_modules ./node_modules COPY . . @@ -54,7 +49,6 @@ COPY . . ENV NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED 1 - RUN pnpm build FROM jellydn/alpine-nodejs:18 AS runner @@ -64,7 +58,6 @@ COPY --from=builder /home/nodejs/app/.next/standalone ./standalone COPY --from=builder /home/nodejs/app/public /home/nodejs/app/standalone/public COPY --from=builder /home/nodejs/app/.next/static /home/nodejs/app/standalone/.next/static - # Clustering RUN npm install -g pm2 @@ -78,14 +71,8 @@ COPY --chown=nodejs:nodejs healthCheck.js ./healthCheck.js CMD ["node", "./standalone/server.js"] - - - - # This marks the end of the second layer. At this stage, we have the static files which we will push to our final image. - - # copy project definition/dependencies files, for better reuse of layers # COPY --chown=nodejs:nodejs package.json ./ @@ -96,7 +83,6 @@ CMD ["node", "./standalone/server.js"] # IMPORTANT: NOT BUILDING, USING PREBUILT - # Production image, copy all the files and run next # FROM timbru31/node-alpine-git:hydrogen AS runner # WORKDIR /home/nodejs/app @@ -124,8 +110,7 @@ CMD ["node", "./standalone/server.js"] # ENV PORT 3000 - # Using Containers? We got your back. Start today using pm2-runtime, a perfect companion to get the most out of Node.js in production environment. # we're not using pm2 in containers waste of time and resources # CMD ["pnpm", "start"] -# CMD ["pnpm", "pm2"] \ No newline at end of file +# CMD ["pnpm", "pm2"] diff --git a/scripts/deploy-to-prod.sh b/scripts/deploy-to-prod.sh index 0681756..27f3ff2 100644 --- a/scripts/deploy-to-prod.sh +++ b/scripts/deploy-to-prod.sh @@ -2,4 +2,4 @@ echo "Deploying to production..." sleep 5 -echo "🚀 Deployed to production! (Moved 20GB of data)" \ No newline at end of file +echo "🚀 Deployed to production! (Moved 20GB of data)" diff --git a/scripts/gitpod-before.sh b/scripts/gitpod-before.sh index 26b7815..de2a5f7 100755 --- a/scripts/gitpod-before.sh +++ b/scripts/gitpod-before.sh @@ -1,28 +1,28 @@ #!/bin/bash source ./scripts/gitpod-env.sh - [[ ! -z $WAKATIME_API_KEY_64 ]] - echo $WAKATIME_API_KEY_64 | base64 -d > ~/.wakatime.cfg - mkdir -p ~/.ssh - [[ ! -z $SSH_PUBLIC_KEY ]] - echo $SSH_PUBLIC_KEY > ~/.ssh/id_rsa.pub - chmod 644 ~/.ssh/id_rsa.pub - [[ ! -z $SSH_PRIVATE_KEY ]] - echo $SSH_PRIVATE_KEY | base64 -d > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - [[ ! -z $GITCONFIG ]] - echo $GITCONFIG | base64 -d > ~/.gitconfig - chmod 644 ~/.gitconfig - git config --global --unset gpg.program - git config --global --unset core.editor - git config --global --unset safe.directory - git config --global user.name BrycensRanch - git config --global user.email brycengranville@outlook.com - export GIT_AUTHOR_NAME="Brycen G" - export GIT_AUTHOR_EMAIL="brycengranville@outlook.com" - [[ ! -z $GNUPG_KEY ]] - rm -rf ~/.gnupg - gpg --verbose --batch --import <(echo $GNUPG_KEY|base64 -d) - echo 'pinentry-mode loopback' >> ~/.gnupg/gpg.conf - git config --global user.signingkey $GPG_KEY_ID - git config --global commit.gpgsign true \ No newline at end of file +[[ ! -z $WAKATIME_API_KEY_64 ]] +echo $WAKATIME_API_KEY_64 | base64 -d > ~/.wakatime.cfg +mkdir -p ~/.ssh +[[ ! -z $SSH_PUBLIC_KEY ]] +echo $SSH_PUBLIC_KEY > ~/.ssh/id_rsa.pub +chmod 644 ~/.ssh/id_rsa.pub +[[ ! -z $SSH_PRIVATE_KEY ]] +echo $SSH_PRIVATE_KEY | base64 -d > ~/.ssh/id_rsa +chmod 600 ~/.ssh/id_rsa +[[ ! -z $GITCONFIG ]] +echo $GITCONFIG | base64 -d > ~/.gitconfig +chmod 644 ~/.gitconfig +git config --global --unset gpg.program +git config --global --unset core.editor +git config --global --unset safe.directory +git config --global user.name BrycensRanch +git config --global user.email brycengranville@outlook.com +export GIT_AUTHOR_NAME="Brycen G" +export GIT_AUTHOR_EMAIL="brycengranville@outlook.com" +[[ ! -z $GNUPG_KEY ]] +rm -rf ~/.gnupg +gpg --verbose --batch --import <(echo $GNUPG_KEY | base64 -d) +echo 'pinentry-mode loopback' >> ~/.gnupg/gpg.conf +git config --global user.signingkey $GPG_KEY_ID +git config --global commit.gpgsign true diff --git a/scripts/gitpod-env.sh b/scripts/gitpod-env.sh index 513c073..3773a23 100755 --- a/scripts/gitpod-env.sh +++ b/scripts/gitpod-env.sh @@ -3,10 +3,10 @@ # Gitpod-enhanced has some ENHANCED issues. export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" source "$HOME/.sdkman/bin/sdkman-init.sh" -nvm install -nvm use \ No newline at end of file +nvm install +nvm use diff --git a/scripts/init-database.sh b/scripts/init-database.sh index 91d92f2..a45e2a2 100644 --- a/scripts/init-database.sh +++ b/scripts/init-database.sh @@ -1,10 +1,10 @@ #!/bin/bash set -e -psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL - CREATE USER $POSTGRES_USER; - CREATE DATABASE $POSTGRES_DB; - GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DB TO $POSTGRES_USER; - CREATE DATABASE $POSTGRES_DB; - GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DB TO $POSTGRES_USER; -EOSQL \ No newline at end of file +psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<- EOSQL + CREATE USER $POSTGRES_USER; + CREATE DATABASE $POSTGRES_DB; + GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DB TO $POSTGRES_USER; + CREATE DATABASE $POSTGRES_DB; + GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DB TO $POSTGRES_USER; +EOSQL diff --git a/scripts/run-migrations.sh b/scripts/run-migrations.sh index b207f99..afdaedd 100755 --- a/scripts/run-migrations.sh +++ b/scripts/run-migrations.sh @@ -2,4 +2,4 @@ # Run those PESKY prisma database migrations for our docker container # This script is run by the docker container on startup -cd backend && pnpm prisma migrate deploy \ No newline at end of file +cd backend && pnpm prisma migrate deploy diff --git a/scripts/sign-tags.sh b/scripts/sign-tags.sh index 0f56d98..f4f1283 100755 --- a/scripts/sign-tags.sh +++ b/scripts/sign-tags.sh @@ -2,8 +2,8 @@ # Check if the script is running in a CI environment (GitHub Actions) if [ "$CI" = "true" ] || [ "$CI" = "1" ] || [ -n "$GITHUB_ACTIONS" ]; then - echo "This script is intended for personal use by the maintainer and should not be used in a CI environment (GitHub Actions included)." - exit 1 + echo "This script is intended for personal use by the maintainer and should not be used in a CI environment (GitHub Actions included)." + exit 1 fi # Get the list of tags in the repository @@ -12,15 +12,15 @@ TAGS=$(git tag) # Display a warning and ask for confirmation read -p "This script is for personal use by the maintainer only and should not be used in a CI environment. Are you sure you want to proceed? (yes/no): " CONFIRM if [ "$CONFIRM" != "yes" ]; then - echo "Operation canceled." - exit 1 + echo "Operation canceled." + exit 1 fi # Loop through each tag, sign it with the default GPG key, and preserve the existing message for TAG in $TAGS; do - TAG_MESSAGE=$(git show -s --format=%B "$TAG") # Get the existing tag message - echo "Signing tag: $TAG" - git tag -s "$TAG" -f -m "$TAG_MESSAGE" "$TAG" # Sign with the existing message + TAG_MESSAGE=$(git show -s --format=%B "$TAG") # Get the existing tag message + echo "Signing tag: $TAG" + git tag -s "$TAG" -f -m "$TAG_MESSAGE" "$TAG" # Sign with the existing message done # Force-push the signed tags to the remote repository