Skip to content

Commit

Permalink
feat: 🎸 add docker
Browse files Browse the repository at this point in the history
  • Loading branch information
yeukfei02 committed Apr 20, 2022
1 parent 53c8cdc commit fa43eec
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:14.18-alpine

RUN mkdir -p /usr/src/app

WORKDIR /usr/src/app

COPY ./ .

RUN yarn

RUN yarn run build

EXPOSE 3000

CMD [ "yarn", "start:prod" ]
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,21 @@ $ yarn run prisma:format
// open prisma studio
$ yarn run prisma:studio
```
## Docker
```zsh
// build images and start container in one line
docker-compose up -d --build

// go inside container
docker exec -it <containerId> /bin/bash

// check container logs
docker logs <containerId>

// remove and stop container
docker-compose down
```
open localhost:3000
48 changes: 48 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: '3.7'

services:
web:
container_name: dummy-api
build:
context: .
dockerfile: Dockerfile
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
ports:
- 3000:3000
restart: always
environment:
- NODE_ENV=production
depends_on:
- db

db:
container_name: postgres
image: postgres:12.1
volumes:
- ./prisma/schema.sql:/docker-entrypoint-initdb.d/dump.sql
ports:
- 5432:5432
restart: always
environment:
POSTGRES_USER: donaldwu
POSTGRES_PASSWORD: donaldwu
POSTGRES_DB: donaldwu

prisma-studio:
container_name: prisma-studio
build:
context: .
command: yarn run prisma:studio
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
ports:
- 5555:5555
restart: always
environment:
- NODE_ENV=production
depends_on:
- web
- db

0 comments on commit fa43eec

Please sign in to comment.