Skip to content

Commit

Permalink
Merge pull request #122 from devsargam/feat/setup-docker
Browse files Browse the repository at this point in the history
Feat: setup docker
  • Loading branch information
hkirat authored Mar 2, 2024
2 parents e509831 + dffc74c commit 580868e
Show file tree
Hide file tree
Showing 10 changed files with 269 additions and 553 deletions.
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

0 comments on commit 580868e

Please sign in to comment.