Skip to content

Commit 1c7c077

Browse files
authored
Merge pull request #88 from mohammadll/add-ui-dockerfile
Add UI Dockerfile and include the UI service in Docker Compose
2 parents 6a2c668 + 7bf8f00 commit 1c7c077

3 files changed

Lines changed: 58 additions & 4 deletions

File tree

docker-compose.yml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,39 @@
11
version: '3.6'
22

33
services:
4-
web:
5-
build: .
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
68
image: 81318131/fastapi_gpt
79
container_name: fastapi_gpt
8-
command: fastapi run app/main.py --port 80
10+
command: fastapi run app/main.py --port 8080
911
volumes:
1012
- './app:/code/app'
1113
environment:
1214
OPENAI_API_KEY: ${KEY:-}
1315
TEST: ${TEST:-}
1416
ports:
15-
- "80:80"
17+
- "8080:8080"
18+
networks:
19+
- app_network
20+
21+
web:
22+
build:
23+
context: ./web
24+
dockerfile: Dockerfile
25+
args:
26+
VITE_API_CLIENT_BASE_URL: "http://localhost:8080"
27+
image: 81318131/web_gpt
28+
container_name: web_gpt
29+
ports:
30+
- "80:4173"
31+
depends_on:
32+
- app
33+
networks:
34+
- app_network
35+
36+
37+
networks:
38+
app_network:
39+
driver: bridge

web/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM node:18-alpine AS builder
2+
ARG VITE_API_CLIENT_BASE_URL
3+
ENV VITE_API_CLIENT_BASE_URL=${VITE_API_CLIENT_BASE_URL}
4+
WORKDIR /app
5+
RUN npm install -g pnpm
6+
COPY package.json pnpm-lock.yaml ./
7+
RUN pnpm install
8+
COPY . .
9+
RUN pnpm run build
10+
11+
FROM nginx:stable-alpine AS production
12+
WORKDIR /usr/share/nginx/html
13+
RUN rm -rf ./*
14+
COPY --from=builder /app/dist ./
15+
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
16+
EXPOSE 4173
17+
CMD ["nginx", "-g", "daemon off;"]

web/nginx/nginx.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
server{
2+
listen 4173;
3+
4+
location / {
5+
root /usr/share/nginx/html;
6+
index index.html index.htm;
7+
try_files $uri $uri/ /index.html;
8+
}
9+
10+
location /notFound {
11+
return 404;
12+
}
13+
}

0 commit comments

Comments
 (0)