Skip to content

Commit ea3aeb5

Browse files
committed
Merge branch 'main' of github.com:snigdho611/docker-compose-react-nodejs-postgres-tutorial
2 parents b03e9cf + a894e49 commit ea3aeb5

File tree

10 files changed

+57
-48
lines changed

10 files changed

+57
-48
lines changed

.env

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
POSTGRES_USER=john_doe
2+
POSTGRES_PASSWORD=john.doe
3+
POSTGRES_DB=docker_test_db
4+
DATABASE_URL=postgresql://john_doe:john.doe@postgres:5432/docker_test_db?schema=public
5+
PORT=8000
6+
VITE_SERVER_URL=http://127.0.0.1:7999

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
node_modules/
22
docker_test_db/
3-
.env
3+
*/.env

client/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ FROM node:18
22
ARG VITE_SERVER_URL=http://127.0.0.1:7999
33
ENV VITE_SERVER_URL=$VITE_SERVER_URL
44
WORKDIR /client
5-
COPY package.json ./
6-
COPY package-lock.json ./
7-
COPY . .
5+
COPY public/ /client/public
6+
COPY src/ /client/src
7+
COPY index.html /client/
8+
COPY package.json /client/
9+
COPY vite.config.js /client/
810
RUN npm install
911
RUN npm run build

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ services:
88
POSTGRES_USER: "${POSTGRES_USER}"
99
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
1010
POSTGRES_DB: ${POSTGRES_DB}
11+
volumes:
12+
- ./docker_test_db:/var/lib/postgresql/data
1113
healthcheck:
1214
test: ["CMD-SHELL", "sh -c 'pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}'"]
1315
interval: 5s

server/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
FROM node:18
2-
ARG DATABASE_URL="postgresql://john_doe:john.doe@postgres:5432/docker_test_db?schema=public"
3-
ENV DATABASE_URL=$DATABASE_URL
2+
# ARG DATABASE_URL="postgresql://john_doe:john.doe@postgres:5432/docker_test_db?schema=public"
3+
# ENV DATABASE_URL=$DATABASE_URL
44
WORKDIR /server
5-
COPY package.json ./
6-
COPY package-lock.json ./
7-
COPY . .
5+
COPY src/ /server/src
6+
COPY prisma/ /server/prisma
7+
COPY package.json /server/
88
RUN npm install
99
RUN npx prisma generate

server/package-lock.json

Lines changed: 32 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "crud-server-express",
33
"version": "1.0.0",
44
"description": "",
5-
"main": "app.js",
5+
"main": "src/app.js",
66
"dependencies": {
7-
"@prisma/client": "^5.14.0",
7+
"@prisma/client": "^5.15.0",
88
"cors": "^2.8.5",
99
"dotenv": "^16.4.5",
1010
"express": "^4.18.2",
@@ -14,13 +14,13 @@
1414
"seed": "node ./prisma/seed.js"
1515
},
1616
"scripts": {
17-
"dev": "nodemon app.js",
18-
"start": "node app.js",
17+
"dev": "nodemon src/app.js",
18+
"start": "node src/app.js",
1919
"test": "echo \"Error: no test specified\" && exit 1"
2020
},
2121
"author": "",
2222
"license": "ISC",
2323
"devDependencies": {
24-
"prisma": "^5.14.0"
24+
"prisma": "^5.15.0"
2525
}
26-
}
26+
}

server/app.js renamed to server/src/app.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const express = require("express");
22
const app = express();
33
const router = express.Router();
44
const cors = require("cors");
5-
// const users = require("./server/users.json");
65
const dotenv = require("dotenv");
76
const HTTP_STATUS = require("./constants/httpStatus");
87
const prisma = require("./config/database");
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)