Skip to content

Commit

Permalink
docker integration with bind mounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Akash1000x committed Apr 17, 2024
1 parent 65da048 commit 7681fcb
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
build
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:20-alpine

WORKDIR /usr/src/app

COPY . .

RUN yarn install

EXPOSE 3000

CMD ["yarn", "run", "dev:docker"]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Quick Setup Locally

* Docker

```
docker compose watch
```

OR

> Install the Dependencies
```
Expand Down
44 changes: 44 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: '3.5'
services:
app:
build: .
container_name: daily-code-docker
environment:
- DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres
ports:
- '3000:3000'
depends_on:
db:
condition: service_healthy
develop:
watch:
- action: sync
path: ./
target: /usr/src/app
ignore:
- node_modules/
- action: rebuild
path: package.json

db:
image: postgres:alpine
container_name: db
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
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

volumes:
postgres-data:
external: false

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"lint": "turbo lint",
"lint:fix": "turbo lint:fix",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"prepare": "husky"
"prepare": "husky",
"dev:docker":"npm run prisma:docker && yarn run dev",
"prisma:docker":"cd packages/db && npx prisma migrate dev --skip-seed && npx prisma db seed"
},
"devDependencies": {
"@commitlint/cli": "^18.6.0",
Expand Down

0 comments on commit 7681fcb

Please sign in to comment.