Skip to content

Commit

Permalink
Merge branch 'evelina/teacher-profile-unstyled' into evelina/teacher-…
Browse files Browse the repository at this point in the history
…management
  • Loading branch information
135ze committed Sep 28, 2024
2 parents e4904b0 + 941a7c4 commit 24a847f
Show file tree
Hide file tree
Showing 14 changed files with 3,846 additions and 2,108 deletions.
10 changes: 7 additions & 3 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ AUTH_GOOGLE_ID=
AUTH_GOOGLE_SECRET=
AUTH_SECRET=
DATABASE_URL=
EMAIL_PASS=
EMAIL_SERVICE=
EMAIL_USER=
GDRIVE_CLIENT_EMAIL=
GDRIVE_CLIENTID=
GDRIVE_PRIVTKEY=
GDRIVE_PROJECTID=
GDRIVE_CLIENT_ID=
GDRIVE_PRIVATE_KEY=
GDRIVE_PROJECT_ID=
POSTGRES_DATABASE=
POSTGRES_PASSWORD=
POSTGRES_PORT=
POSTGRES_URL_NON_POOLING=
POSTGRES_USER=
32 changes: 0 additions & 32 deletions .github/workflows/deploy.yml

This file was deleted.

20 changes: 17 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,28 @@ FROM node:20-alpine
# Set the working directory
WORKDIR /sistema

# Copy package.json and package-lock.json
# Copy package.json, package-lock.json, and prisma directory
COPY package.json package-lock.json ./
COPY prisma ./prisma

# Install dependencies using npm
RUN npm install

# Copy the rest of the application code
COPY . .

# Copy environment variables
COPY .env* ./

# Expose the port the app runs on
EXPOSE 3000

# Start the Next.js application in development mode
CMD ["npm", "run", "dev"]
# Run the application
CMD echo "Waiting for database to be ready..." && \
echo "Running Prisma commands..." && \
npx prisma generate && \
npx prisma db push && \
npx @snaplet/seed sync && \
npx prisma db seed && \
echo "Starting Next.js application..." && \
npm run dev
44 changes: 39 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ npm install

## Secrets

- Create A [HashiCorp Clous Cloud Platform Account](https://portal.cloud.hashicorp.com/sign-in?ajs_aid=9085f07d-f411-42b4-855b-72795f4fdbcc&product_intent=vault)
- Create A [HashiCorp Cloud Platform Account](https://portal.cloud.hashicorp.com/sign-in?ajs_aid=9085f07d-f411-42b4-855b-72795f4fdbcc&product_intent=vault)
- Install [HashiCorp Vault](https://developer.hashicorp.com/hcp/tutorials/get-started-hcp-vault-secrets/hcp-vault-secrets-install-cli#install-hcp-vault-secrets-cli) in order to pull secrets
- Log in to Vault
- In the folder where you cloned the Sistema repository, log into Vault

```bash
vlt login
hcp auth login
```

- Configure the Vault Command Line Interface

```bash
vlt config init
hcp profile init
```

- Select the `sistema` Organization and Project
Expand Down Expand Up @@ -126,6 +126,13 @@ docker system prune -a --volumes

### Accessing PostgreSQL Database

Run in two lines:
```bash
docker exec -it sistema-db-1 psql -U sistema -d sistema
SELECT * FROM public."Absence";
```

Running the commands line by line.
```bash
# run a bash shell in the container
docker exec -it sistema-db-1 /bin/bash
Expand All @@ -139,7 +146,34 @@ psql -U sistema -d sistema
# quit
\q
# you can run any SQL query, don't forget the semicolon!
SELECT * FROM <table-name>;
SELECT * FROM public."<table-name>";
```

### Seeding the Database
** Database seeds automatically when docker compose build --up is run. Only run the following commands if the auto seeding fails.

Full Commands for Manual Seeding:
- Local: In schema.prisma, set env to DATABASE_URL. Ensure the database is running locally
- Production: Repull secrets and set to VERCEL_DATABASE_NON_POOLING. Then seed Manually

```bash
npx prisma generate; npx prisma db push; npx @snaplet/seed sync; npx prisma db seed
```

Run the following commands:

```bash
npx prisma generate
npx prisma db push
```

```bash
# In the root directory to sync seed.ts to the current data models of the database
npx @snaplet/seed sync

# Seeding the database according to seed.ts
npx prisma db seed

```

## Formatting and Linting
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
- POSTGRES_DATABASE=${POSTGRES_DATABASE}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_PORT=${POSTGRES_PORT}
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DATABASE}
db:
image: postgres:16-alpine
ports:
Expand Down
Loading

0 comments on commit 24a847f

Please sign in to comment.