Skip to content

Commit

Permalink
dockerizing project by creating containers for app & postgres (#110)
Browse files Browse the repository at this point in the history
fix minor issue in deployment of render

latest commit

 Update Readme file to include Docker-specific information

 Update Readme file to include Docker-specific information
  • Loading branch information
wayneleon1 authored May 31, 2024
1 parent f7e2d7f commit d8d8721
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/node_modules
/coverage
Dockerfile
.dockerignore
docker-compose.yaml
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:latest

WORKDIR /usr/src/app

COPY package*.json ./
RUN npm install

COPY . .

EXPOSE 3000
CMD ["npm", "run", "dev"]
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ To get started with Dynamites API, follow these simple steps:
npm run test:ci
```

## Docker

Before you run that commands you must have docker installed in your PC

1. **Build the Docker Image:**
```sh
docker build -t <image_name> .
```
2. **Use Docker Compose to run Containers :**
```sh
docker-compose up
```
3. **Stop the Running Containers:**
- If running with Docker Compose:
```sh
docker-compose down
```
## Usage

Once the development server is running, you can interact with the API using HTTP requests.
Expand Down
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: '3'
services:
db:
image: postgres
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD_DEV}
POSTGRES_USER: ${DB_USER_DEV}
POSTGRES_DB: ${DB_NAME_DEV}
ports:
- '5431:5432'

app:
build: .
ports:
- '8080:3000'
depends_on:
- db
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
env_file:
- .env
2 changes: 1 addition & 1 deletion src/config/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ const config: {
production,
};

export default config[env];
export default config[env];

0 comments on commit d8d8721

Please sign in to comment.