Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0112b35eee | |||
| 7b90cac1d1 | |||
| 894a6f01c2 | |||
| 9896850b49 |
@@ -5,6 +5,10 @@ WORKDIR /app
|
|||||||
|
|
||||||
# Copy go.mod and go.sum files to download dependencies
|
# Copy go.mod and go.sum files to download dependencies
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
|
|
||||||
|
# Install the C compiler (gcc) and other build tools needed for CGO
|
||||||
|
RUN apk add --no-cache build-base
|
||||||
|
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
# Copy the rest of the application source code
|
# Copy the rest of the application source code
|
||||||
@@ -13,7 +17,7 @@ COPY . .
|
|||||||
# Build the application
|
# Build the application
|
||||||
# CGO_ENABLED=0 is important for a clean static build for Alpine
|
# CGO_ENABLED=0 is important for a clean static build for Alpine
|
||||||
# -o main specifies the output file name
|
# -o main specifies the output file name
|
||||||
RUN go build -o main .
|
RUN CGO_ENABLED=1 go build -o main .
|
||||||
|
|
||||||
# Stage 2: Create the final lightweight image
|
# Stage 2: Create the final lightweight image
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ COPY . .
|
|||||||
# The output will be in the /app/dist/ directory
|
# The output will be in the /app/dist/ directory
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
# Debugging: List the contents of the build output directory
|
||||||
|
RUN ls -laR /app/dist/frontend
|
||||||
|
|
||||||
# Stage 2: Serve the application with Nginx
|
# Stage 2: Serve the application with Nginx
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
@@ -24,9 +27,12 @@ RUN rm /etc/nginx/conf.d/default.conf
|
|||||||
# Copy the custom Nginx configuration from the local machine
|
# Copy the custom Nginx configuration from the local machine
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
# Remove default Nginx welcome page
|
||||||
|
RUN rm -rf /usr/share/nginx/html/*
|
||||||
|
|
||||||
# Copy the built application from the builder stage to Nginx's web root directory
|
# Copy the built application from the builder stage to Nginx's web root directory
|
||||||
# I am assuming the project name is 'dashboard'. If not, you may need to change the path 'dist/dashboard/browser'.
|
# I am assuming the project name is 'dashboard'. If not, you may need to change the path 'dist/dashboard/browser'.
|
||||||
COPY --from=builder /app/dist/frontend /usr/share/nginx/html
|
COPY --from=builder /app/dist/frontend/ /usr/share/nginx/html
|
||||||
|
|
||||||
# Expose port 80 for the web server
|
# Expose port 80 for the web server
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|||||||
Reference in New Issue
Block a user