Skip to content

Commit

Permalink
#169817536 Setup docker
Browse files Browse the repository at this point in the history
[Finishes #169817536]
  • Loading branch information
victor-abz authored and adesege committed Dec 5, 2019
1 parent acb1a82 commit 425b4ad
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
npm-debug.log
.git
dist
5 changes: 4 additions & 1 deletion .env-sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
//N.B: When writting the below credentials ommit the curl braces.
# N.B: When writting the below credentials ommit the curl braces.

DB_URL=postgres://{db_username}:{db_password}@{host}:{port}/{db_name}
TOKEN_SECRET= "your_secret"
POSTGRES_USER={db_user}
POSTGRES_PASSWORD={db_password}
POSTGRES_DB={db_name}
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:12.13.0

WORKDIR /app

COPY package*.json ./

RUN npm install --quiet

COPY . .

EXPOSE 3000

CMD ["npm", "run", "dev"]
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type in the search bar `eslint`
Set eslint to lint `on save`
Set eslint to run `as you type`

## Installation and usage instructions
## Installation and usage instructions with Node

* Clone the repository using: `git clone https://github.com/andela/the_spinners-backend.git `
* Copy the file ***.env.sample*** then rename it to ***.env*** input the right credentials.
Expand All @@ -63,6 +63,17 @@ Set eslint to run `as you type`
* Run `npm start` To start the application in ***production environment***
* Run `npm test` to run test

## Run application with Docker
* Install Docker on your machine
* Clone the repository using: `git clone https://github.com/andela/the_spinners-backend.git `
* Copy the file ***.env.sample*** then rename it to ***.env***.
* In the `.env file` Set database host as `db`
* Set the following `POSTGRES_USER=your_db_user_name`
- `POSTGRES_PASSWORD=User_PASSWORD`
- `POSTGRES_DB=POSTGRES_DB`
* Run `docker-compose up` To run the application with docker
* wait to see the message `Listening on port 3000.......`


## Features
* User can sign up
Expand Down
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3"
services:
node:
build: .
restart: always
ports:
- 3000:3000
depends_on:
- db
db:
image: postgres:9.4
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
volumes:
- db_data:/var/lib/postgresql/data
volumes:
db_data:

0 comments on commit 425b4ad

Please sign in to comment.