Skip to content

Commit

Permalink
Merge pull request #105 from GTBitsOfGood/hc/103-dockerize
Browse files Browse the repository at this point in the history
hc/103-dockerize
  • Loading branch information
tmthecoder authored Oct 13, 2023
2 parents 0823ed9 + 3bfed4f commit 6d30d02
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 1,771 deletions.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"presets": ["next/babel"]}
6 changes: 5 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint && npm run format
if [ "$USE_DOCKER" = "true" ]; then
NODE_COMMAND=lint docker-compose up --build --exit-code-from app app && NODE_COMMAND=format docker-compose up --build --exit-code-from app app
else
npm run lint && npm run format
fi
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:16
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm ci
EXPOSE 3000
RUN /bin/bash
ENV NODE_COMMAND=dev

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

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

ENTRYPOINT ["sh", "-c", "npm run $NODE_COMMAND"]
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,37 @@

1. Clone this project to your computer
2. Navigate to this project in your terminal
### Use with Docker
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 install -g @bitwarden/cli fx`

Or, if you're using Homebrew, run `brew install bitwarden-cli fx`

Now fetch the secrets from BitWarden with `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 with `npm install -g @bitwarden/cli fx`

Now fetch the secrets from BitWarden with `yarn secrets:login` and `yarn secrets:sync`

5. Run `docker-compose up --build` to run the dev environment

To run build or any other script specified in the package.json, provide the NODE_COMMAND environment variable before docker-compose like `NODE_COMMAND=build docker-compose up --build`

### Use without Docker

__Note__: You might want to remove the .babelrc file from your local directory to enable SWC, a faster compiler for Next.js than Babel. __This will break Docker__.

3. Run `npm ci` to retrieve dependencies
4. Run `npm run secrets` to sync secrets to `.env.local`
- You will be asked for a password, ask your EM to send it to you
Expand Down
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3"

services:
app:
build:
context: .
environment:
- NODE_COMMAND=${NODE_COMMAND:-dev}
- COMMIT_MSG=${COMMIT_MSG:-""}
ports:
- "3000:3000"
env_file:
- .env.local
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
2 changes: 2 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
command = "npm run build"
Loading

0 comments on commit 6d30d02

Please sign in to comment.