File tree Expand file tree Collapse file tree 6 files changed +23
-37
lines changed Expand file tree Collapse file tree 6 files changed +23
-37
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,4 @@ WORKDIR /todo_api
9
9
COPY --from=builder /todo_api ./
10
10
RUN yarn install --production=true
11
11
EXPOSE 8080
12
- ENTRYPOINT ["yarn" , "serve" ]
12
+ ENTRYPOINT ["yarn" ]
Original file line number Diff line number Diff line change @@ -8,35 +8,23 @@ Make sure you have [Docker](https://www.docker.com/) installed
8
8
9
9
### Setting up
10
10
11
- ** Commands**
12
-
13
- To install the database management, run:
14
-
15
- ``` bash
16
- docker-compose up -d
17
- ```
18
-
19
- To create database, run:
20
-
21
- ``` bash
22
- docker exec -it todo psql -U postgres -c " create database todo"
23
- ```
24
-
25
11
** .env file**
26
12
27
13
1 . Create the ` .env ` file
28
14
2 . Copy and parse the ` connection information ` below:
29
15
30
16
``` bash
31
- DB_USER=postgres
32
- DB_HOST=localhost
33
- DB_DATABASE=todo
34
- DB_PORT=54320
17
+ POSTGRES_USER=docker
18
+ POSTGRES_PASSWORD=docker
19
+ POSTGRES_HOST=localhost
20
+ POSTGRES_DB=todo
21
+ POSTGRES_PORT=54320
35
22
```
36
23
37
- ## Create tables
38
-
39
- Open and run the ` database/sql/database.sql ` by postgres tools (i.e. [ pgAdmin] ( https://www.pgadmin.org/ ) )
24
+ ** database**
25
+ ``` bash
26
+ docker-compose up -d
27
+ ```
40
28
41
29
## Seeding data
42
30
Original file line number Diff line number Diff line change 1
- create database todo ;
2
-
3
1
create table todo_list
4
2
(
5
3
id serial primary key not null ,
Original file line number Diff line number Diff line change @@ -3,9 +3,9 @@ services:
3
3
db :
4
4
image : " postgres:11"
5
5
container_name : " todo"
6
+ env_file :
7
+ - ./.env
6
8
ports :
7
9
- " 54320:5432"
8
10
volumes :
9
- - todo:/var/lib/postgresql/data
10
- volumes :
11
- todo:
11
+ - ./database/sql/database.sql:/docker-entrypoint-initdb.d/database.sql
Original file line number Diff line number Diff line change @@ -3,11 +3,11 @@ require('dotenv').config();
3
3
4
4
function connect ( ) {
5
5
return new Pool ( {
6
- user : process . env . DB_USER ,
7
- host : process . env . DB_HOST ,
8
- database : process . env . DB_DATABASE ,
9
- password : process . env . DB_PASSWORD ,
10
- port : process . env . DB_PORT ,
6
+ user : process . env . POSTGRES_USER ,
7
+ host : process . env . POSTGRES_HOST ,
8
+ database : process . env . POSTGRES_DB ,
9
+ password : process . env . POSTGRES_PASSWORD ,
10
+ port : process . env . POSTGRES_PORT ,
11
11
} ) ;
12
12
}
13
13
Original file line number Diff line number Diff line change @@ -3,10 +3,10 @@ require('dotenv').config();
3
3
4
4
export function connect ( ) {
5
5
return new Pool ( {
6
- user : process . env . DB_USER ,
7
- host : process . env . DB_HOST ,
8
- database : process . env . DB_DATABASE ,
9
- password : process . env . DB_PASSWORD ,
10
- port : process . env . DB_PORT ,
6
+ user : process . env . POSTGRES_USER ,
7
+ host : process . env . POSTGRES_HOST ,
8
+ database : process . env . POSTGRES_DB ,
9
+ password : process . env . POSTGRES_PASSWORD ,
10
+ port : process . env . POSTGRES_PORT ,
11
11
} ) ;
12
12
}
You can’t perform that action at this time.
0 commit comments