forked from kubestellar/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
37 lines (27 loc) · 813 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Stage 1: Build frontend
FROM node:18 AS frontend-builder
# Set working directory
WORKDIR /app
# Install Git
RUN apt-get update && apt-get install -y git
# Copy package files for caching
COPY package.json package-lock.json ./
RUN npm install --legacy-peer-deps
# Copy source code
COPY . .
# Explicitly copy .git to access commit hash
COPY .git .git
# Extract Git commit hash
RUN git rev-parse HEAD > commit_hash.txt
ENV VITE_BASE_URL=http://localhost:4000
ENV VITE_APP_VERSION=0.1.0
# Build frontend
RUN npm run build
# Store commit hash inside the build output
RUN mv commit_hash.txt dist/
# Stage 2: Serve with Nginx
FROM nginx:alpine AS frontend
COPY --from=frontend-builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]