From 07d0616c0517c7be2f2dae3039af25e78b3c097e Mon Sep 17 00:00:00 2001
From: Johnny <44646589+Junnyyy@users.noreply.github.com>
Date: Sat, 1 Apr 2023 16:54:04 -0500
Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=94=A8=20Created=20DockerFile?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Dockerfile | 22 +++-------------------
1 file changed, 3 insertions(+), 19 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 28b99a26..4837fb1c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,32 +1,16 @@
-FROM node:14.19.1-alpine3.14 AS build
+FROM node:16-alpine3.14 AS build
-ENV NODE_ENV prod
-
-WORKDIR /app
+RUN apk add g++ make py3-pip
COPY package.json .babelrc ./
RUN npm install
-COPY ./src ./src
+COPY . .
RUN npm run build \
&& npm prune --production
-
-FROM node:14.19.1-alpine3.14
-
-WORKDIR /app
-
-RUN chown -R 1000:1000 /app \
- && chmod 755 /app
-
-USER 1000
-
-COPY --from=build /app/node_modules ./node_modules
-
-COPY --from=build /app/dist ./dist
-
EXPOSE ${PORT}
CMD ["node", "./dist/server.js"]
\ No newline at end of file
From 1a53772b6234fd12325e3ab1b2869d9a90562d5d Mon Sep 17 00:00:00 2001
From: Johnny <44646589+Junnyyy@users.noreply.github.com>
Date: Sat, 1 Apr 2023 17:03:35 -0500
Subject: [PATCH 2/4] =?UTF-8?q?=E2=9C=85=20Add=20--no-cache=20and=20WORKDI?=
=?UTF-8?q?R?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Dockerfile | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Dockerfile b/Dockerfile
index 4837fb1c..ad0b64b2 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,6 +1,8 @@
FROM node:16-alpine3.14 AS build
-RUN apk add g++ make py3-pip
+WORKDIR /app
+
+RUN apk add g++ make py3-pip --no-cache
COPY package.json .babelrc ./
From 90a180df774dcba302c72d1fda9290fc8bcdbb6d Mon Sep 17 00:00:00 2001
From: Johnny <44646589+Junnyyy@users.noreply.github.com>
Date: Sat, 1 Apr 2023 17:10:41 -0500
Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=90=9B=20Fix=20node-gyp=20dependencie?=
=?UTF-8?q?s?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Dockerfile.dev | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/Dockerfile.dev b/Dockerfile.dev
index 74cb835a..e04e8245 100644
--- a/Dockerfile.dev
+++ b/Dockerfile.dev
@@ -1,17 +1,15 @@
-FROM node:14.19.1-alpine3.14 AS development
-
-ENV NODE_ENV dev
+FROM node:16-alpine3.14 AS development
WORKDIR /app
-COPY package.json .babelrc ./
+RUN apk add g++ make py3-pip --no-cache
-COPY yarn.lock .
+COPY yarn.lock package.json ./
RUN yarn
COPY . .
-EXPOSE 4000
+EXPOSE ${PORT}
-CMD [ "yarn", "server" ]
\ No newline at end of file
+CMD ["yarn", "server"]
\ No newline at end of file
From 77fff82df07b676f07803cc17bb79ee3e869eb4f Mon Sep 17 00:00:00 2001
From: Johnny <44646589+Junnyyy@users.noreply.github.com>
Date: Sat, 1 Apr 2023 17:23:39 -0500
Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=93=9D=20Update=20readme?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 51 ++++++++++++++++++++++++++++++++++-----------------
1 file changed, 34 insertions(+), 17 deletions(-)
diff --git a/README.md b/README.md
index 8524d943..4e74a6a0 100644
--- a/README.md
+++ b/README.md
@@ -28,35 +28,51 @@ Offical backend of CougarCS.
- ## Requirements
- [NodeJS](https://nodejs.org/en/) version 14+
- We use [Yarn](https://yarnpkg.com/getting-started/install) as our package manager
+ - [Docker](https://www.docker.com/)
- ## Installation
- Install dependencies: `yarn`
- Start local server: `yarn server`
- The local server will start on [http://localhost:4000](http://localhost:4000)
- ## ENV Setup:
+
- If you want to test out the payment or the reCAPTCHA, create a `.env` file in the root project folder.
- You must have a [Stripe](https://stripe.com/), [Google's reCAPTCHA](https://www.google.com/recaptcha/about/), and [SendGrid](https://sendgrid.com) accounts.
- NEW_RELIC_ENABLED must be disabled (`NEW_RELIC_ENABLED=false`) in development.
- In the `.env` file include these:
+
```
- SENDGRID_API_KEY
- CALENDAR_ID
- CALENDAR_API_KEY
- SHEET_API
- RECAPTCHA_SECRET_KEY
- STRIPE_API_KEY
- SENTRY_URL
- SEND_EMAIL
- INGESTION_KEY
- NOTION_TOKEN
- NOTION_TUTOR_DB
- COUGARCS_CLOUD_URL
- COUGARCS_CLOUD_ACCESS_KEY
- COUGARCS_CLOUD_SECRET_KEY
- NEW_RELIC_ENABLED
- SUPABASE_URL
- SUPABASE_KEY
+ PORT
+ SENDGRID_API_KEY
+ CALENDAR_ID
+ CALENDAR_API_KEY
+ SHEET_API
+ RECAPTCHA_SECRET_KEY
+ STRIPE_API_KEY
+ SENTRY_URL
+ SEND_EMAIL
+ NOTION_TOKEN
+ NOTION_TUTOR_DB
+ YOUTUBE_API_KEY
+ YOUTUBE_PLAYLIST_ID
+ COUGARCS_CLOUD_URL
+ COUGARCS_CLOUD_ACCESS_KEY
+ COUGARCS_CLOUD_SECRET_KEY
+ NEW_RELIC_LICENSE_KEY
+ NEW_RELIC_APP_NAME
+ SUPABASE_URL
+ SUPABASE_KEY
```
+
- Reach out to the Webmaster(webmaster@cougarcs.com) for the env values
+
+- ## Docker Usage
+
+- Development Docker:
+ - Build the image run `docker build -t -f Dockerfile.dev .`
+ - Create a container run `docker run -dp : --env-file .env `
+- Production Docker:
+ - Build the image run `docker build -t .`
+ - Create a container run `docker run -dp : --env-file .env `
- ## Linting
- We use ESLint to fix styling and to enforce rules.
@@ -89,6 +105,7 @@ Offical backend of CougarCS.
- We use [Coveralls](https://coveralls.io/github/CougarCS/CougarCS-Backend) to track the coverage.
- ## Project Structure
+
- `server.js` is the starting point of the application
- `src/api/routes/` has the routes of the applications
- `src/config/app.js` sets up the middlewares