-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #293 from CougarCS/Dockertize
🔨 Docker Refactor
- Loading branch information
Showing
3 changed files
with
43 additions
and
42 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 |
---|---|---|
@@ -1,32 +1,18 @@ | ||
FROM node:14.19.1-alpine3.14 AS build | ||
|
||
ENV NODE_ENV prod | ||
FROM node:16-alpine3.14 AS build | ||
|
||
WORKDIR /app | ||
|
||
RUN apk add g++ make py3-pip --no-cache | ||
|
||
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"] |
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,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" ] | ||
CMD ["yarn", "server"] |
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 |
---|---|---|
|
@@ -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. | ||
- <strong>NEW_RELIC_ENABLED must be disabled (`NEW_RELIC_ENABLED=false`) in development.</strong> | ||
- 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([email protected]) for the env values | ||
|
||
- ## Docker Usage | ||
|
||
- Development Docker: | ||
- Build the image run `docker build -t <image-name> -f Dockerfile.dev .` | ||
- Create a container run `docker run -dp <docker-port>:<external-port> --env-file .env <image-name>` | ||
- Production Docker: | ||
- Build the image run `docker build -t <image-name> .` | ||
- Create a container run `docker run -dp <docker-port>:<external-port> --env-file .env <image-name>` | ||
- ## 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 | ||
|