質問編集履歴

2

docker-compose.ymlなどの修正

2021/08/26 05:28

投稿

RyoS_
RyoS_

スコア4

test CHANGED
File without changes
test CHANGED
@@ -76,78 +76,66 @@
76
76
 
77
77
 
78
78
 
79
- networks:
80
-
81
- container-link:
82
-
83
-
84
-
85
79
  services:
86
80
 
87
81
  # MySQL
88
82
 
89
83
  db:
90
84
 
85
+ image: mysql:5.7
86
+
87
+ environment:
88
+
89
+ MYSQL_DATABASE: $MYSQL_DATABASE
90
+
91
+ MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
92
+
93
+ TZ: $TZ
94
+
95
+ volumes:
96
+
97
+ - db-data:/var/lib/mysql
98
+
99
+ - db-data:/etc/mysql/conf.d/my.cnf
100
+
101
+ ports:
102
+
103
+ - $DB_PORT:3306
104
+
105
+
106
+
107
+ #【backend】Express
108
+
109
+ app:
110
+
91
111
  build:
92
112
 
93
- context: ./docker/mysql
113
+ context: ./docker/app
94
-
114
+
95
- args:
115
+ environment:
96
-
97
- MYSQL_DATABASE: $MYSQL_DATABASE
116
+
98
-
99
- MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
100
-
101
- TZ: $TZ
117
+ TZ: $TZ
118
+
119
+ DEBUG: $BACKEND_DEBUG
120
+
121
+ DATABASE_URL: $BACKEND_DATABASE_URL
122
+
123
+ tty: true
124
+
125
+ ports:
126
+
127
+ - $BACKEND_PORT:18080
128
+
129
+ restart: always
102
130
 
103
131
  volumes:
104
132
 
105
- - db-data:/var/lib/mysql
106
-
107
- ports:
108
-
109
- - $DB_PORT:3306
110
-
111
- networks:
112
-
113
- - container-link
114
-
115
-
116
-
117
- #【backend】Express
118
-
119
- app:
120
-
121
- build:
122
-
123
- context: ./docker/app
124
-
125
- environment:
126
-
127
- - TZ=Asia/Tokyo
128
-
129
- - DEBUG=api:*
130
-
131
- tty: true
132
-
133
- ports:
134
-
135
- - $BACKEND_PORT:18080
136
-
137
- restart: always
138
-
139
- volumes:
140
-
141
133
  - $BACKEND_DIR:$BACKEND_WORK_DIR
142
134
 
143
135
  working_dir: $BACKEND_WORK_DIR
144
136
 
145
137
  command: [sh, -c, npm install && npm run build && npm run start]
146
138
 
147
- networks:
148
-
149
- - container-link
150
-
151
139
  ```
152
140
 
153
141
 
@@ -194,6 +182,10 @@
194
182
 
195
183
  BACKEND_WORK_DIR = "/node"
196
184
 
185
+ BACKEND_DEBUG = "api:*"
186
+
187
+ BACKEND_DATABASE_URL = "mysql://root:password@db:6306/Nuxt-Express-TypeScript"
188
+
197
189
  ```
198
190
 
199
191
 
@@ -232,40 +224,6 @@
232
224
 
233
225
 
234
226
 
235
- #### Dockerfile <db>
236
-
237
-
238
-
239
- ```
240
-
241
- FROM mysql:5.7
242
-
243
-
244
-
245
- ARG MYSQL_DATABASE
246
-
247
- ARG MYSQL_ROOT_PASSWORD
248
-
249
- ARG TZ
250
-
251
-
252
-
253
- ENV MYSQL_DATABASE=${MYSQL_DATABASE} \
254
-
255
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \
256
-
257
- TZ=${TZ}
258
-
259
-
260
-
261
- COPY ./my.cnf /etc/mysql/conf.d/my.cnf
262
-
263
- RUN chmod 644 /etc/mysql/conf.d/my.cnf
264
-
265
- ```
266
-
267
-
268
-
269
227
  #### prisma/schema.prisma
270
228
 
271
229
 
@@ -276,7 +234,7 @@
276
234
 
277
235
  provider = "mysql"
278
236
 
279
- url = "mysql://root:password@db:6306/Nuxt-Express-TypeScript"
237
+ url = env("DATABASE_URL")
280
238
 
281
239
  }
282
240
 

1

修正

2021/08/26 05:28

投稿

RyoS_
RyoS_

スコア4

test CHANGED
File without changes
test CHANGED
@@ -10,6 +10,8 @@
10
10
 
11
11
 
12
12
 
13
+
14
+
13
15
  以下のコードで、Prismaのマイグレーションを行ったのですがエラーが発生します。
14
16
 
15
17