質問編集履歴

2

追記

2020/10/19 02:39

投稿

NakaShun_1129
NakaShun_1129

スコア20

test CHANGED
File without changes
test CHANGED
@@ -40,7 +40,7 @@
40
40
 
41
41
 
42
42
 
43
- WORKDIR /usr/src/app
43
+ WORKDIR /app
44
44
 
45
45
 
46
46
 
@@ -54,4 +54,86 @@
54
54
 
55
55
  COPY . .
56
56
 
57
+
58
+
59
+ CMD [ "npm", "run", "start"]
60
+
57
61
  ```
62
+
63
+
64
+
65
+
66
+
67
+ ```
68
+
69
+ version: "3.7"
70
+
71
+
72
+
73
+ services:
74
+
75
+ app:
76
+
77
+ build: ./app
78
+
79
+ working_dir: /app
80
+
81
+ context: /app
82
+
83
+ dockerfile: Dockerfile
84
+
85
+ volumes:
86
+
87
+ - ./app:/app
88
+
89
+ environment:
90
+
91
+ - DB_HOST=db
92
+
93
+ - DB_PORT=5432
94
+
95
+ - DB_USER=postgres
96
+
97
+ - DB_PASSWORD=password
98
+
99
+ - DB_DATABASE_NAME=testdb
100
+
101
+ - NODE_ENV=development
102
+
103
+
104
+
105
+ db:
106
+
107
+ image: postgres:12.2
108
+
109
+ ports:
110
+
111
+ - "5432:5432"
112
+
113
+ environment:
114
+
115
+ - POSTGRES_PASSWORD=password
116
+
117
+ - PGPASSWORD=password
118
+
119
+ - POSTGRES_DB=testdb
120
+
121
+ - DATABASE_HOST=localhost
122
+
123
+
124
+
125
+ ```
126
+
127
+
128
+
129
+ 追記:
130
+
131
+ ローカル上に同じDockerfileでコンテナを動かすと、packege.jsonはWORKDIRに存在しています。
132
+
133
+ ```
134
+
135
+ root@c828b55a1adf:/app# ls
136
+
137
+ Dockerfile Makefile assets coverage dist jest.config.js migration node_modules ormconfig.js package-lock.json package.json src test tsconfig.json tsconfig.paths.json webpack.config.js
138
+
139
+ ```

1

内容修正

2020/10/19 02:39

投稿

NakaShun_1129
NakaShun_1129

スコア20

test CHANGED
File without changes
test CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
 
27
- docker build -t {コンテナ名} -f ./app/Dockerfile .
27
+ docker build -t {イメージ名} -f ./app/Dockerfile .
28
28
 
29
29
 
30
30