Skip to content

Commit

Permalink
Add db init to docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
akelsch committed Jul 6, 2020
1 parent 21a6529 commit 8153748
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 20 deletions.
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
# dashboard-prototyp
# corona-dashboard

Project as part of the web applications module at htw saar. It contains a backend application built with Express serving COVID-19 case data provided by RKI.

## Endpoints

See [Postman collection](etc/Corona%20Backend.postman_collection.json).

## Getting Started

### TLDR

1. `git clone`
2. `npm install`
3. `docker-compose up -d`
4. `npm run init`
5. `npm start`

### npm

#### `npm install`
Expand All @@ -28,24 +42,22 @@ Running the following command will start a PostgreSQL database including PostGIS
docker-compose up -d
```

To run and build the application with Docker uncomment the `app` part in [`docker-compose.yml`](docker-compose.yml) and run:
If you want to dockerize the application itself as well, add [`docker-compose.prod.yml`](docker-compose.prod.yml) to your list of compose files:

```sh
docker-compose up -d --build
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build
```

#### pgAdmin

1. Go to http://localhost:8000/
2. Login using admin/nimda
1. Open http://localhost:8000/
2. Login
- Username: admin
- Password: nimda
3. Create a new server
1. Host: postgres
2. Port: 5432
3. Username: postgres
4. Password: postgres
- Host: postgres
- Port: 5432
- Username: postgres
- Password: mysecretpassword

Note that the server configuration is persistent and will survive restarts.

## Endpoints

See [Postman collection](etc/Corona%20Backend.postman_collection.json).
10 changes: 10 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3.4'

services:
app:
build: .
command: sh -c "npm run init && npm start"
ports:
- 3000:3000
environment:
PG_HOST: postgres
6 changes: 1 addition & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
version: '3.4'

services:
# app:
# build: .
# ports:
# - 3000:3000
postgres:
image: postgis/postgis
ports:
- 5432:5432
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_PASSWORD: mysecretpassword
volumes:
- pgdata:/var/lib/postgresql/data
pgadmin:
Expand Down
5 changes: 3 additions & 2 deletions lib/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ const { Sequelize } = sequelize

const DATABASE = 'postgres'
const USERNAME = 'postgres'
const PASSWORD = 'postgres'
const PASSWORD = 'mysecretpassword'
const HOST = process.env.PG_HOST || 'localhost'

const connection = new Sequelize(DATABASE, USERNAME, PASSWORD, {
host: 'localhost',
host: HOST,
dialect: 'postgres'
})

Expand Down

0 comments on commit 8153748

Please sign in to comment.