Skip to content

Commit

Permalink
style(repo): run prettier and eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
BrycensRanch committed Nov 18, 2023
1 parent 59692a2 commit 647f018
Show file tree
Hide file tree
Showing 22 changed files with 67 additions and 107 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ frontend/node_modules
#**/**/*out*
**/**/*reports*
**/**/*.nyc_output*

2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Auto line endings
* text=auto eol=lf
* text=auto eol=lf
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
/cypress-coverage
/reports


**/node_modules/
npmlist.json

Expand Down Expand Up @@ -43,8 +42,6 @@ sentry.server.config.js
public/sitemap*.xml
public/robots.txt



# production
/build

Expand Down
2 changes: 1 addition & 1 deletion .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
_
_
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm exec commitlint --edit $1
pnpm exec commitlint --edit $1
4 changes: 2 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ frontend/reports/
.nyc_output/
frontend/.nyc_output/
.pnpm-store/
backend/prisma/json-schema/
backend/prisma/json-schema/
18 changes: 2 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check notice on line 18 in Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint (ubuntu-latest)

Multiple consecutive `RUN` instructions. Consider consolidation.



# set right (secure) folder permissions
RUN mkdir -p /home/nodejs/app/node_modules

Check notice on line 21 in Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint (ubuntu-latest)

Multiple consecutive `RUN` instructions. Consider consolidation.
RUN mkdir -p /home/nodejs/app/frontend/node_modules

Check notice on line 22 in Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint (ubuntu-latest)

Multiple consecutive `RUN` instructions. Consider consolidation.
Expand All @@ -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

Check failure on line 36 in Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint (ubuntu-latest)

Do not use sudo as it leads to unpredictable behavior. Use a tool like gosu to enforce root

Check notice on line 36 in Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint (ubuntu-latest)

Multiple consecutive `RUN` instructions. Consider consolidation.

# 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/
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -102,7 +96,6 @@ RUN pnpm build
RUN pnpm prune --config.ignore-scripts=true --prod

Check notice on line 96 in Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint (ubuntu-latest)

Multiple consecutive `RUN` instructions. Consider consolidation.
RUN cd backend && pnpm prune --config.ignore-scripts=true --prod

Check warning on line 97 in Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint (ubuntu-latest)

Use WORKDIR to switch to a directory


FROM ubuntu AS runner

Check warning on line 99 in Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint (ubuntu-latest)

Always tag the version of an image explicitly
RUN adduser --disabled-password --gecos "" nodejs && usermod -a -G nodejs nodejs
RUN apt update && apt install -y curl

Check warning on line 101 in Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint (ubuntu-latest)

Do not use apt as it is meant to be a end-user tool, use apt-get or apt-cache instead
Expand Down Expand Up @@ -132,8 +125,6 @@ RUN rm -rf node_modules
RUN cd backend && npx pnpm install -D prisma --ignore-scripts

Check warning on line 125 in Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint (ubuntu-latest)

Use WORKDIR to switch to a directory
RUN HUSKY=0 npx pnpm install --prod



#RUN npm i -g next

# Work in progress
Expand All @@ -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 . .
Expand All @@ -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 . .
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ backupPostgres
.nyc_output
/cypress


_old
# /*.min.js*

Expand Down Expand Up @@ -64,4 +63,4 @@ Dockerfile
Dockerfile*.*
Jenkinsfile
Jenkinsfile*.*
/jenkins
/jenkins
2 changes: 1 addition & 1 deletion backend/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ prisma/seed.ts
**/out/
**/build/
**/jest-coverage/
**/pnpm-lock.yaml
**/pnpm-lock.yaml
5 changes: 2 additions & 3 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ node_modules
jspm_packages
coverage
jest-coverage
secret-key
secret-key
# secret key for jwt

# Optional npm cache directory
Expand Down Expand Up @@ -64,12 +64,11 @@ profile*
*clinic*
*flamegraph*


dev.db

PostgresData
PostgresData2
dockerApp
DockerRedisCache
backupPostgres
.nyc_output
.nyc_output
13 changes: 5 additions & 8 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,26 +23,23 @@ 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* ./

# Install dependencies
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
Expand Down
2 changes: 1 addition & 1 deletion backend/prisma/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generated
migrations
json-schema
json-schema
2 changes: 1 addition & 1 deletion frontend/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ out
public
jest-coverage
coverage
.next
.next
.swc
**/dist/
**/lib/
Expand Down
4 changes: 1 addition & 3 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ sentry.server.config.js
public/sitemap*.xml
public/robots.txt



# production
/build

Expand All @@ -67,4 +65,4 @@ local
.vercel

# Sentry
.sentryclirc
.sentryclirc
21 changes: 3 additions & 18 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -24,20 +24,16 @@ 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

# Install dependencies based on the preferred package manager
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
Expand All @@ -46,15 +42,13 @@ 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 . .

ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED 1


RUN pnpm build

FROM jellydn/alpine-nodejs:18 AS runner
Expand All @@ -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

Expand All @@ -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 ./

Expand All @@ -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
Expand Down Expand Up @@ -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"]
# CMD ["pnpm", "pm2"]
2 changes: 1 addition & 1 deletion scripts/deploy-to-prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

echo "Deploying to production..."
sleep 5
echo "🚀 Deployed to production! (Moved 20GB of data)"
echo "🚀 Deployed to production! (Moved 20GB of data)"
Loading

0 comments on commit 647f018

Please sign in to comment.