質問編集履歴

2

改変後のdocker-composeを追加しました。

2024/04/12 04:50

投稿

Nakano_Akito
Nakano_Akito

スコア10

test CHANGED
File without changes
test CHANGED
@@ -66,7 +66,7 @@
66
66
  init_db(app)
67
67
  app.run()
68
68
  ```
69
- ```docker-compose.yml
69
+ ```docker-compose.yml(改変前)
70
70
  services:
71
71
  frontend:
72
72
  build:
@@ -87,6 +87,28 @@
87
87
  - ./backend:/usr/src/app
88
88
  - ./frontend/dist:/usr/src/app/frontend/dist
89
89
  command: flask run --host=0.0.0.0
90
+ ```
91
+ ```docker-compose.yml(改変後)
92
+ services:
93
+ frontend:
94
+ build:
95
+ context: ./frontend
96
+ dockerfile: Dockerfile
97
+ command: npm run dev
98
+ ports:
99
+ - '5173:5173'
100
+ volumes:
101
+ - ./frontend:/usr/src/app
102
+ backend:
103
+ build:
104
+ context: ./backend
105
+ dockerfile: Dockerfile
106
+ command: ["python3", "app.py", "--host=0.0.0.0"]
107
+ ports:
108
+ - '5000:5000'
109
+ volumes:
110
+ - ./backend:/usr/src/app
111
+ - ./frontend/dist:/usr/src/app/frontend/dist
90
112
  ```
91
113
  ```backendの方のDockerfile
92
114
  FROM python:3.12.2

1

docker-compose.ymlと、backendの方のDockerfileを追加しました。

2024/04/12 01:24

投稿

Nakano_Akito
Nakano_Akito

スコア10

test CHANGED
File without changes
test CHANGED
@@ -66,6 +66,42 @@
66
66
  init_db(app)
67
67
  app.run()
68
68
  ```
69
+ ```docker-compose.yml
70
+ services:
71
+ frontend:
72
+ build:
73
+ context: ./frontend
74
+ dockerfile: Dockerfile
75
+ command: npm run dev
76
+ ports:
77
+ - '5173:5173'
78
+ volumes:
79
+ - ./frontend:/usr/src/app
80
+ backend:
81
+ build:
82
+ context: ./backend
83
+ dockerfile: Dockerfile
84
+ ports:
85
+ - '5000:5000'
86
+ volumes:
87
+ - ./backend:/usr/src/app
88
+ - ./frontend/dist:/usr/src/app/frontend/dist
89
+ command: flask run --host=0.0.0.0
90
+ ```
91
+ ```backendの方のDockerfile
92
+ FROM python:3.12.2
93
+
94
+ WORKDIR /usr/src/app
95
+
96
+ COPY ./ /usr/src/app/
97
+ COPY ./requirements.txt ./
98
+
99
+ RUN pip install --upgrade pip
100
+ RUN pip install --upgrade flask
101
+ RUN pip install -r requirements.txt
102
+ RUN pip install flask_sqlalchemy
103
+ RUN pip install flask-restful
104
+ ```
69
105
 
70
106
  ### 試したこと
71
107