Skip to content

Commit

Permalink
Merge branch 'main' into MigrateDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
avenmia authored Oct 15, 2023
2 parents f1b3c34 + 99fa40e commit 6b3bd0f
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 20 deletions.
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# For SQLServer
DATABASE_URL="sqlserver://localhost: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_FROM="[email protected]"
NEXT_PUBLIC_POLIS_SURVEYS='[{"id": "yourSurveyID1", "title": "yourSurveyTitle1", "description": "yourSurveyDescription1"}]'
NEXT_PUBLIC_SEARCH_API='{your ArcGIS Search Api Key}'
AUTHORIZED_POLIS_CONVERT_EMAILS_FILE={path to file that contains a list of email addresses (one per line) whose users are authorized to export POLIS data}
8 changes: 3 additions & 5 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ jobs:
cache: "npm"

- run: npm ci
- name: Make envfile
uses: SpicyPizza/[email protected]
with:
envkey_NEXT_PUBLIC_POLIS_SURVEYS: ${{ secrets.NEXT_PUBLIC_POLIS_SURVEYS }}
- run: SKIP_ENV_VALIDATION=1 npm run build --if-present
- name: Create .env file
run: cp -f .env.example .env
- run: npm run build --if-present
env:
CI: true
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ yarn-error.log*
# do not commit any .env files to git, except for the .env.example file. https://create.t3.gg/en/usage/env-variables#using-environment-variables
.env
.env*.local
.env.example

# vercel
.vercel
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/hydrogen
15 changes: 15 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
sql:
image: mcr.microsoft.com/mssql/server:2017-latest
environment:
ACCEPT_EULA: Y
MSSQL_SA_PASSWORD: <YourStrong@Passw0rd>
ports:
- 1433:1433
smtp:
image: rnwood/smtp4dev:v3
ports:
- 3001:80
- 25:25
environment:
- ServerOptions__HostName=smtp4dev
65 changes: 51 additions & 14 deletions src/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,61 @@
# Local project installation and setup

```
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
touch .env
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
```

Next, create database table `HIERR`. Enter the bash shell in the docker image:

```bash
docker exec -it hierr-sql-1 "bash"
```

Enter the SQL Server CLI tool

```bash
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "<YourStrong@Passw0rd>"
```

Create a new database and check that it was created

```bash
CREATE DATABASE HIERR;
SELECT Name from sys.databases;
GO
```

- Add the following to the .env:
1. DATABASE_URL="file:./db.sqlite"
2. NEXTAUTH_URL="http://localhost:3000"
3. EMAIL_SERVER={your email server}
4. EMAIL_FROM={the email to send the verification link}
5. NEXT_PUBLIC_POLIS_SURVEYS='[{"id": "{yourSurveyID1}", "title": "{yourSurveyTitle1}", "description", "{yourSurveyDescription1}"}, ...]'
6. NEXT_PUBLIC_SEARCH_API='{your ArcGIS Search Api Key}'
7. AUTHORIZED_POLIS_CONVERT_EMAILS_FILE={path to file that contains a list of email addresses (one per line) whose users are authorized to export POLIS data}
Then, you may exit:

```bash
exit
```

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

```bash
npx prisma migrate dev
npx prisma db push
# Run dev server on http://localhost:3000
npm run dev
```

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

# Update Prisma

Run these commands for specific Prisma tasks.

1. Update schema.prisma with your model

Validate your prisma model
Expand All @@ -49,7 +82,9 @@ Update the database
npx prisma db push
```

# SMTP Server Setup
# SMTP Cloud Server Setup

Follow these directions for setting up an SMTP server in the cloud, as opposed to setting one up on your local machine.

- Gmail
- Follow the steps at this YouTube video for setting up an SMTP gmail account
Expand All @@ -67,13 +102,15 @@ npx prisma db push

# Prisma SQL Server Migration

Follow these directions for easier database editing.

- Windows
- Install SQL Server
- Docker
- [Docker Microsoft SQL Server Images Download](https://hub.docker.com/_/microsoft-mssql-server)
- docker pull mcr.microsoft.com/mssql/server:2017-latest
- Start SQL Server (2017)
- docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=yourStrong(!)Password" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest
- docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=<YourStrong@Passw0rd>" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest
- Microsoft
- [Miscrosoft SQL Server Download](https://www.microsoft.com/en-us/sql-server/sql-server-downloads)
- Enable SQL Server TCP/IP
Expand All @@ -86,10 +123,10 @@ npx prisma db push
- SQL Server 2019 (local install):
- sqlserver://localhost:1433;initial catalog=HIERR;integratedSecurity=true;trustServerCertificate=true;
- SQL Server 2017 (docker):
- sqlserver://localhost:1433;database=HIERR;user=sa;password=yourStrong(!)Password;encrypt=DANGER_PLAINTEXT;
- sqlserver://localhost:1433;database=HIERR;user=sa;password=<YourStrong@Passw0rd>;encrypt=DANGER_PLAINTEXT;
- Note: Connection string uses the default user and password from docker. Also the DANGER_PLAINTEXT is used because of an issue with TLS.
- Other OS systems:
- sqlserver://HOST:PORT;database=HIERR;user=USER;password=PASSWORD;encrypt=true
- sqlserver://HOST:PORT;database=HIERR;user=sa;password=<YourStrong@Passw0rd>;encrypt=true
- Note: Be sure to change USER and PASSWORD to your system's requirements
- Docs: https://www.prisma.io/docs/concepts/database-connectors/sql-server
- Run the following prisma commands
Expand Down

0 comments on commit 6b3bd0f

Please sign in to comment.