@@ -8,7 +8,7 @@ RUN ["pip", "install", "pipenv"]
8
8
RUN ["sh" , "-c" , "pipenv requirements --dev > requirements.txt" ]
9
9
RUN ["rm" , "Pipfile" , "Pipfile.lock" ]
10
10
11
- FROM python:3.12 as build-server
11
+ FROM python:3.12 as build-server-deps
12
12
13
13
# Path: /app
14
14
WORKDIR /app
@@ -19,26 +19,43 @@ RUN ["python3", "-m", "venv", "/venv"]
19
19
ENV PATH="/venv/bin:$PATH"
20
20
RUN ["python3" , "-m" , "pip" , "install" , "-r" , "requirements.txt" ]
21
21
22
+ FROM node:20 as build-frontend-deps
23
+
24
+ # Path: /tmp/
25
+ WORKDIR /tmp/
26
+
27
+ COPY ./frontend/package.json frontend/package.json
28
+ WORKDIR /tmp/frontend
29
+ RUN ["npm" , "install" ]
30
+
31
+ FROM python:3.12 as build-server-openapi
32
+
33
+ WORKDIR /app
34
+
35
+ COPY --from=build-server-deps /venv /venv
36
+
22
37
COPY src/main.py src/main.py
23
38
COPY dump_openapi.py .
24
39
ENV FASTAPI_OPENAPI_OUTPUT="/tmp/openapi.json"
25
40
RUN ["mkdir" , "-p" , "frontend/dist" ]
41
+
42
+ ENV PATH="/venv/bin:$PATH"
26
43
RUN ["python3" , "dump_openapi.py" ]
27
44
28
45
FROM node:20 as build-frontend
29
46
30
- # Path: /tmp/
31
- WORKDIR /tmp/
47
+ COPY --from=build-server-openapi /tmp/openapi.json /tmp/openapi.json
48
+ COPY ./frontend /tmp/frontend
49
+ COPY --from=build-frontend-deps /tmp/frontend/node_modules /tmp/frontend/node_modules
32
50
33
- COPY ./frontend frontend
34
51
WORKDIR /tmp/frontend
35
- RUN ["npm" , "install" ]
36
- COPY --from=build-server /tmp/openapi.json /tmp/openapi.json
52
+
37
53
RUN ["npx" , "openapi-typescript" , "/tmp/openapi.json" , "-o" , "src/api/schema.d.ts" ]
38
54
RUN ["npm" , "run" , "build" ]
39
55
40
56
FROM python:3.12-slim as production
41
- COPY --from=build-server /venv /venv
57
+
58
+ COPY --from=build-server-deps /venv /venv
42
59
COPY src/main.py .
43
60
COPY --from=build-frontend /tmp/frontend/dist ./frontend/dist
44
61
ENV PATH="/venv/bin:$PATH"
0 commit comments