Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerize Boggers #64

Merged
merged 4 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ yarn-error.log*
next-env.d.ts
# Local Netlify folder
.netlify

bitwarden.env
12 changes: 12 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:16 AS deps
WORKDIR /app

COPY package.json yarn.lock ./
RUN yarn config set network-timeout 600000 -g
RUN yarn install --legacy-peer-deps

FROM node:16 as dev

WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,23 @@ Boggers is still growing and we hope to add many new features to facilitate club

## Getting Started

Run the development server:
### Run With Docker

1. Install [Docker](https://docs.docker.com/engine/install/)
2. Obtain the Bitwarden password from your EM. Create a `bitwarden.env` file and fill it in with the following contents:
```
BW_PASSWORD=<your bitwarden password>
```
This only needs to be done on your first run. After that, you should delete the file from your repository to avoid pushing it to Github.
3. Start the application with Docker Compose: `docker compose up`

If you make any changes to the packages, you may need to rebuild the images. To do this, append --build to the above docker compose up command.

The Dockerized application will have live-reloading of changes made on the host machine.

Note: On linux-based operating systems, if you come across an entrypoint permission error (i.e. `process: exec: "./entrypoint.sh": permission denied: unknown`), run `chmod +x ./entrypoint.sh` to make the shell file an executable.

### Run the development server:

```bash
yarn dev
Expand Down
1 change: 1 addition & 0 deletions bitwarden.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BW_PASSWORD=<your bitwarden password>
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
app:
env_file:
- bitwarden.env
build:
dockerfile: ./Dockerfile.dev
volumes:
- ./:/app
- /app/node_modules
- /app/.next
ports:
- "3000:3000"
entrypoint: ./entrypoint.sh
20 changes: 20 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

if [ ! -f "./.env" ]; then
echo "Secrets not found. Pulling files from Bitwarden..."
if [[ -z "${BW_PASSWORD}" ]]; then
echo "Error: BW_PASSWORD envvar is not defined. Please inject BW_PASSWORD into container!"
exit 1;
fi

npm install -g @bitwarden/cli fx
# get secrets
bw logout
export BW_SESSION=$(bw login [email protected] ${BW_PASSWORD} --raw);
bw sync --session $BW_SESSION
bw get item c2786b92-f3e9-404e-9288-b089015adf37 | fx .notes > ".env.local"

echo "Secrets successfully retrieved."
fi

yarn run dev
Loading