fixing dockerfile
This commit is contained in:
parent
193bb427d2
commit
a8d825c573
|
|
@ -1,41 +1,28 @@
|
|||
# Build stage
|
||||
FROM node:20-alpine as build
|
||||
FROM node:18-alpine AS builder
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Tambahkan dependensi yang mungkin dibutuhkan
|
||||
RUN apk add --no-cache python3 make g++ git
|
||||
# Copy package.json and package-lock.json
|
||||
COPY package.json package-lock.json ./
|
||||
|
||||
# Copy package files dan install dependencies
|
||||
COPY package.json package-lock.json* ./
|
||||
# Gunakan --legacy-peer-deps untuk mengatasi masalah kompatibilitas
|
||||
RUN npm ci --legacy-peer-deps || npm install --legacy-peer-deps
|
||||
# Install dependencies
|
||||
RUN npm install
|
||||
|
||||
# Copy kode aplikasi
|
||||
# Copy project files
|
||||
COPY . .
|
||||
|
||||
# Build aplikasi
|
||||
# Build the project
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
# Use Nginx for serving static files
|
||||
FROM nginx:alpine
|
||||
|
||||
# Copy file hasil build ke nginx
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
|
||||
# Buat konfigurasi nginx untuk SPA routing
|
||||
RUN echo 'server { \
|
||||
listen 80; \
|
||||
server_name _; \
|
||||
root /usr/share/nginx/html; \
|
||||
index index.html; \
|
||||
location / { \
|
||||
try_files $uri $uri/ /index.html; \
|
||||
} \
|
||||
}' > /etc/nginx/conf.d/default.conf
|
||||
# Copy build files to Nginx html directory
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
# Expose port 80
|
||||
EXPOSE 80
|
||||
|
||||
# Start nginx
|
||||
# Start Nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
|
|
|||
Loading…
Reference in New Issue