diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..90f069c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +/node_modules +/coverage +Dockerfile +.dockerignore +docker-compose.yaml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..93fc512 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM node:latest + +WORKDIR /usr/src/app + +COPY package*.json ./ +RUN npm install + +COPY . . + +EXPOSE 3000 +CMD ["npm", "run", "dev"] diff --git a/README.md b/README.md index 48dba2f..2831285 100644 --- a/README.md +++ b/README.md @@ -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 . + ``` +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. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..dae5931 --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/src/config/db.ts b/src/config/db.ts index 6082fa0..4a0acf5 100644 --- a/src/config/db.ts +++ b/src/config/db.ts @@ -47,4 +47,4 @@ const config: { production, }; -export default config[env]; \ No newline at end of file +export default config[env];