Skip to content

Commit

Permalink
Merge pull request #186 from GTBitsOfGood/hc/dockerize
Browse files Browse the repository at this point in the history
Dockerize and move to Netlify
  • Loading branch information
tmthecoder authored Sep 25, 2023
2 parents 61b0814 + 62162ad commit 2c3d196
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit "$1"
COMMIT_MSG=$1 YARN_COMMAND=commitlint docker-compose up --build --exit-code-from earthcraft earthcraft
4 changes: 2 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint:fix
yarn prettier
YARN_COMMAND=lint:fix docker-compose up --build --exit-code-from earthcraft earthcraft
YARN_COMMAND=prettier docker-compose up --build --exit-code-from earthcraft earthcraft
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn build
YARN_COMMAND=build docker-compose up --build --exit-code-from earthcraft earthcraft
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:16
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn install
EXPOSE 3000
ENV YARN_COMMAND=dev

# If you want to use a different command, pass the YARN_COMMAND env variable to
# docker-compose up --build

# Ex. YARN_COMMAND=build docker-compose up --build

ENTRYPOINT ["sh", "-c", "yarn $YARN_COMMAND"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 GT Bits of Good
Copyright (c) 2023 GT Bits of Good

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
119 changes: 106 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Make sure you have gone through this walkthrough and all the links down below:
- [Code Tour](/CODETOUR.md)
- [Engineering Onboarding Guide](https://gtbitsofgood.notion.site/Engineering-Onboarding-Guide-a22683c9388a4b9fb03de442f6664aae)
- [Figma/Design](https://www.figma.com/file/YTJqtLkjyxYdS3UkfR9dza/Southface-%2F-Fall22?node-id=0%3A1&t=HjMuBBxgKAeaLCzm-1)
- [Netlify Production Build](https://southface.netlify.app)

## Stack

Expand All @@ -32,6 +33,76 @@ git clone https://github.com/GTBitsOfGood/southface.git
cd southface
```

## Running with Docker (recommended):

3. Install **docker** and **docker-compose**

MacOS: [Docker Desktop for MacOS](https://docs.docker.com/desktop/install/mac-install/)

Windows: [Docker Desktop for Windows](https://docs.docker.com/desktop/install/windows-install/)

Linux: [Docker Desktop for Linux](https://docs.docker.com/desktop/install/linux-install/)

4. Obtain your secrets -- **Linux or MacOS** (Skip if Windows); you will need to obtain a password from your Engineering Manager:

First, install **BitWarden CLI** and **fx** with npm

```
npm install -g @bitwarden/cli fx
```

Or, if you're using Homebrew,

```
brew install bitwarden-cli fx
```

Now fetch the secrets from BitWarden

```
yarn secrets:linux
```

4. Obtain your secrets -- **Windows Machines** (Skip if MacOS or Linux); you will need to obtain a password from your Engineering Manager:

First, install **BitWarden CLI** and **fx** with npm

```
npm install -g @bitwarden/cli fx
```

Now fetch the secrets from BitWarden

```
yarn secrets:windows
```

Contact your EM for the Bitwarden password. **NEVER EVER** commit `.env.local` to your version control system.

5. Run the app

To run the dev environment, run the default docker-compose command

```
docker-compose up --build
```

To run build or any other script specified in the package.json, provide the YARN_COMMAND environment variable before docker-compose

```
YARN_COMMAND=build docker-compose up --build
```

### Development

- Run `docker-compose up --build`

### Production

- Run `YARN_COMMAND=start docker-compose up --build`

## Running outside of Docker (not recommended):

3. Install Node Version Manager (NVM)

- follow [this guide](https://www.freecodecamp.org/news/node-version-manager-nvm-install-guide/) if you don't have NVM already to install it onto your machine.
Expand All @@ -42,38 +113,47 @@ cd southface
nvm install 16 && nvm use 16
```

4. Install the dependencies (make sure to use yarn and not npm):
5. Install the dependencies (make sure to use yarn and not npm):

```
yarn
```

5. Obtain your secrets -- Linux or MacOS (Skip if Windows); you will need to obtain a password from your Engineering Manager:
4. Obtain your secrets -- **Linux** or **MacOS** (Skip if Windows); you will need to obtain a password from your Engineering Manager:

First, install **BitWarden CLI** with npm

```
yarn secrets:linux
npm install -g @bitwarden/cli
```

5. Obtain your secrets -- Windows Machines (Skip if MacOS or Linux); you will need to obtain a password from your Engineering Manager:
Or, if you're using Homebrew,

```
yarn secrets:windows
brew install bitwarden-cli
```

Contact your EM for the Bitwarden password. **NEVER EVER** commit `.env.local` to your version control system.
Now fetch the secrets from BitWarden

## MongoDB
```
yarn secrets:linux
```

A running instance of MongoDB is required this project.
4. Obtain your secrets -- **Windows Machines** (Skip if MacOS or Linux); you will need to obtain a password from your Engineering Manager:

- Download [mongoDB compass](https://www.mongodb.com/try/download/compass)
- Launch MongoDB Compass. When prompted for the connection URL, copy and paste `DB_URL` from your `.env.local` file.
First, install BitWarden CLI with npm

You should now have write access to the different collections available.
```
npm install -g @bitwarden/cli
```

## Running
Now fetch the secrets from BitWarden

To understand this code better, read the [Code Tour](/CODETOUR.md).
```
yarn secrets:windows
```

Contact your EM for the Bitwarden password. **NEVER EVER** commit `.env.local` to your version control system.

### Development

Expand All @@ -83,6 +163,19 @@ To understand this code better, read the [Code Tour](/CODETOUR.md).

- Run `yarn start`

## MongoDB

If you're using Docker, Docker will run MongoDB inside its container. If you aren't, you'll have to run it yourself. Installing MongoDB Compass will allow you to do that. Regardless, download it so you can view the remote database from your machine.

- Download [MongoDB compass](https://www.mongodb.com/try/download/compass)
- Launch MongoDB Compass. When prompted for the connection URL, copy and paste `DB_URL` from your `.env.local` file.

You should now have write access to the different collections available.

## Running

To understand this code better, read the [Code Tour](/CODETOUR.md).

## Additional Information

- Use `[INITIALS]/[ISSUE_NUMBER]-[SHORT_DESCRIPTION]` when naming your feature branches
Expand Down
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: "3"

services:
earthcraft:
build:
context: .
environment:
- YARN_COMMAND=${YARN_COMMAND:-dev}
- COMMIT_MSG=${COMMIT_MSG:-""}
ports:
- "3000:3000"
env_file:
- .env.local
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
mongo:
image: mongo:latest
ports:
- "27017:27017"
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"secrets:windows": "set /p BW_PASSWORD=Enter Bitwarden Password:&& (bw logout || VER>NUL) && yarn secrets:login",
"secrets:login": "FOR /F %a IN ('bw login [email protected] %BW_PASSWORD% --raw') DO SET BW_SESSION=%a && yarn secrets:get",
"secrets:get": "bw sync && bw get item 8ccfc499-cfc2-4e66-9e82-af0801429e85 | fx .notes > \".env.local\"",
"prepare": "npx husky install"
"prepare": "npx husky install",
"commitlint": "cross-env npx commitlint --edit $COMMIT_MSG"
},
"husky": {
"hooks": {
Expand Down

1 comment on commit 2c3d196

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for southface ready!

✅ Preview
https://southface-396cd4wzd-bitsofgood.vercel.app

Built with commit 2c3d196.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.