Skip to content

Commit

Permalink
Merge pull request #293 from CougarCS/Dockertize
Browse files Browse the repository at this point in the history
🔨 Docker Refactor
  • Loading branch information
bnleft authored Apr 1, 2023
2 parents d9b7d98 + 77fff82 commit 946fe0e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 42 deletions.
22 changes: 4 additions & 18 deletions Dockerfile
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"]
12 changes: 5 additions & 7 deletions Dockerfile.dev
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"]
51 changes: 34 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 946fe0e

Please sign in to comment.