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

Update local development instructions to run fully containerized for dev consistency #216

Merged
merged 4 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# For SQLServer
DATABASE_URL="sqlserver://localhost:1433;database=HIERR;user=sa;password=<YourStrong@Passw0rd>;encrypt=DANGER_PLAINTEXT;"
DATABASE_URL="sqlserver://hierr-sql-1:1433;database=HIERR;user=sa;password=<YourStrong@Passw0rd>;encrypt=DANGER_PLAINTEXT;"
# For SQLite
# DATABASE_URL="file:./db.sqlite"
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET=DUMMY
EMAIL_SERVER="smtp://localhost:25"
EMAIL_SERVER="smtp://hierr-smtp-1:25"
EMAIL_FROM="[email protected]"
NEXT_PUBLIC_POLIS_SURVEYS='[{"id": "yourSurveyID1", "title": "yourSurveyTitle1", "description": "yourSurveyDescription1"}]'
NEXT_PUBLIC_SEARCH_API='{your ArcGIS Search Api Key}'
Expand Down
12 changes: 12 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@ services:
- 25:25
environment:
- ServerOptions__HostName=smtp4dev
node:
image: debian:12-slim
ports:
- 3000:3000
stdin_open: true # used to keep container running
tty: true
user: "${UID_GID}"
environment:
HOME: "${USER_HOME}"
volumes:
- ./:/HIERR
- ${USER_HOME}:${USER_HOME}
24 changes: 20 additions & 4 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ Run these commands to set up and run the project locally for the first time.
```bash
git clone https://github.com/CodeforHawaii/HIERR.git
cd HIERR
# Use nvm to set the NodeJS version https://github.com/nvm-sh/nvm
nvm use
npm install
cp -f .env.example .env # Note: You may have to update the .env file with your specific secret values.
# Use docker to set up SQL and SMTP servers locally https://www.docker.com/
# See "SMTP Cloud Server Setup" and "Prisma SQL Server Migration" sections if
# wanting to use a different set up.
docker compose up -d
UID_GID="$(id -u):$(id -g)" USER_HOME=$HOME docker compose up -d
```

Next, create database table `HIERR`. Enter the bash shell in the docker image:
Expand Down Expand Up @@ -41,15 +38,34 @@ Then, you may exit:
exit
```

Prepare the HIERR container:

```bash
# instal curl in hierr container
docker exec -u 0:0 -it hierr-node-1 bash -c "apt update && apt install -y curl"
# open hierr container and run
docker exec -it hierr-node-1 bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
exit
docker exec -it hierr-node-1 bash
cd /HIERR
nvm install
nvm use
npm install
```

Finally, run the DB migration scripts and run the dev server:

```bash
# still inside the HIERR container...
npx prisma migrate dev
npx prisma db push
# Run dev server on http://localhost:3000
npm run dev
```

You can now access HIERR from http://localhost:3000

The SMTP email web interface is available at http://localhost:3001.

# Update Prisma
Expand Down
Loading