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

Feat: setup docker #122

Merged
merged 7 commits into from
Mar 2, 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: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.git
.gitignore
.env.example
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
NEXT_PUBLIC_BASE_URL_LOCAL=http://127.0.0.1:8000
NEXT_PUBLIC_BASE_URL_LOCAL=http://127.0.0.1:3000
ADMIN_SECRET="ADMIN_SECRET"
JWT_SECRET="JWT_SECRET"
DATABASE_URL=""
# DONT CHANGE FOR RUNNING WITH DOCKER
DATABASE_URL="postgresql://postgres:postgres@db:5432/cms?schema=public"
NEXTAUTH_URL="http://localhost:3000"
APPX_AUTH_KEY="AUTH_SECRET"
NEXTAUTH_SECRET="NEXTAUTH_SECRET"
Expand Down
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:20-alpine

WORKDIR /usr/src/app

COPY package.json package-lock.json ./
COPY prisma ./prisma

RUN npm install

COPY . .

EXPOSE 3000

CMD ["npm", "run", "dev:docker"]
44 changes: 33 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,42 @@
<h1 align='center'>CMS</h1>

## Setup procedure

- Docker

or

- Copy .env.example to .env
- Get a postgres db from https://neon.tech/ (or any other provider)
- replace the DATABASE_URL in .env
- Run `npx prisma migrate dev` to setup schema
- cd migrations, Seed SQL data -

## Setup procedure -
- Copy .env.example to .env
- Get a postgres db from https://neon.tech/ (or any other provider)
- replace the DATABASE_URL in .env
- Run `npx prisma migrate dev` to setup schema
- cd migrations, Seed SQL data -
```
psql -h your_db_host -d your_db -U your_username < neondb_backup.sql
```

For example

```
psql -h ep-super-wildflower-a5sqjjhz.us-east-2.aws.neon.tech -d neondb -U harkirat < neondb_backup.sql
```
- npm install
- npm run dev
- Login using any userid and password 123456
- You should be able to see some test courses

Read [contributing guidelines](./CONTRIBUTING.md) to start making contributions
---

## Steps to run locally

#### With Docker

- docker compose up

#### Without Docker

- npm install
- npm run dev
- Login using any userid and password 123456
- You should be able to see some test courses

---

Read [contributing guidelines](./CONTRIBUTING.md) to start making contributions
26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3.5'
services:
app:
build: .
container_name: cms-docker
environment:
- DATABASE_URL=postgresql://postgres:postgres@db:5432/cms?schema=public
ports:
- '3000:3000'
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
depends_on:
- db

db:
image: postgres:9.6
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: cms
ports:
- 5432:5432
volumes:
- /postgres-data:/var/lib/postgresql/data
Loading
Loading