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

Pr/533 #538

Closed
wants to merge 9 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.git
.gitignore
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:20-alpine

WORKDIR /usr/src/app

COPY package* .

COPY prisma ./prisma

RUN npm install

COPY . .

ENV DATABASE_URL="postgresql://postgres:mysecretpassword@db:5432/paper"

RUN npx prisma generate

EXPOSE 3000

CMD ["npm", "run", "docker-dev"]
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,53 @@ git clone https://github.com/mfts/papermark.git
cd papermark
```

### 2. Install npm dependencies
### Without Docker

#### 2. Install npm dependencies

```shell
npm install
```

### 3. Copy the environment variables to `.env` and change the values
#### 3. Copy the environment variables to `.env` and change the values

```shell
cp .env.example .env
```

### 4. Initialize the database
#### 4. Initialize the database

```shell
npx prisma generate
npx prisma migrate deploy
```

### 5. Run the dev server
#### 5. Run the dev server

```shell
npm run dev
```

### 6. Open the app in your browser
#### 6. Open the app in your browser

Visit [http://localhost:3000](http://localhost:3000) in your browser.

### with Docker

#### 2. Copy the environment variables to `.env` and change the values where the DATABASE_URL="postgresql://postgres:mysecretpassword@db:5432/paper?schema=public"

```shell
cp .env.example .env
```

#### 3. Run docker compose -up

```shell
docker compose up
```


#### 4. Open the app in your browser

Visit [http://localhost:3000](http://localhost:3000) in your browser.

Expand Down
36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: "3.6"
services:
db:
image: postgres
container_name: db
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_DB: paper
POSTGRES_PASSWORD: mysecretpassword
ports:
- 5432:5432
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
interval: 10s
timeout: 5s
retries: 5

app:
build: .
container_name: app
env_file:
- .env
ports:
- "3000:3000"
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
depends_on:
db:
condition: service_healthy

volumes:
postgres-data:
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"node": ">=18.17.0"
},
"scripts": {
"docker-dev":"npx prisma migrate deploy && next dev",
"dev": "next dev",
"build": "next build",
"start": "next start",
Expand Down