Skip to content

Commit c791e4f

Browse files
committed
Adding updates for vite with docker env
1 parent 65e981c commit c791e4f

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

.env.examle renamed to .env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ POSTGRES_USER=
22
POSTGRES_PASSWORD=
33
POSTGRES_DB=
44
DATABASE_URL=
5-
PORT=
5+
PORT=
6+
VITE_SERVER_URL=

client/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_SERVER_URL=

client/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM node:18
2+
ARG VITE_SERVER_URL=http://127.0.0.1:7999
3+
ENV VITE_SERVER_URL=$VITE_SERVER_URL
4+
WORKDIR /client
5+
COPY package.json ./
6+
COPY package-lock.json ./
7+
COPY . .
8+
RUN npm install
9+
RUN npm run build
10+
CMD ["npm", "run", "preview"]

client/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dev": "vite",
88
"build": "vite build",
99
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
10-
"preview": "vite preview"
10+
"preview": "vite preview --host"
1111
},
1212
"dependencies": {
1313
"react": "^18.2.0",
@@ -24,4 +24,4 @@
2424
"eslint-plugin-react-refresh": "^0.4.6",
2525
"vite": "^5.2.0"
2626
}
27-
}
27+
}

docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,15 @@ services:
2323
PORT: "${PORT}"
2424
depends_on:
2525
- postgres
26+
client:
27+
container_name: client
28+
build:
29+
context: ./client
30+
dockerfile: Dockerfile
31+
# command: npm start
32+
ports:
33+
- "4174:4173"
34+
# environment:
35+
# VITE_SERVER_URL: "${VITE_SERVER_URL}"
36+
depends_on:
37+
- server

0 commit comments

Comments
 (0)