From dd1f42e395e83683e51c1aae4e9ba143d35aba8b Mon Sep 17 00:00:00 2001 From: Atif Ather <40694397+atifather@users.noreply.github.com> Date: Thu, 14 Dec 2023 03:12:28 +0500 Subject: [PATCH] Update Dockerfile Signed-off-by: Atif Ather <40694397+atifather@users.noreply.github.com> --- Dockerfile | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Dockerfile b/Dockerfile index e6c0367..c7453c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,55 @@ +# Stage 1: Build the Frontend +FROM node:18.14.1 AS frontend + +# Set the working directory for the frontend +WORKDIR /app + +# Copy the entire project +COPY . /app + +# Install make, required for the build process +RUN apt-get update && apt-get install -y make + +# Change to the ./web directory and build the frontend +WORKDIR /app +RUN make build-web + +# Stage 2: Build the Go application FROM golang:1.20 AS builder + +# Set the working directory for Go application WORKDIR /src + +# Copy Go modules files COPY go.sum go.mod ./ + +# Download Go modules RUN go mod download + +# Copy the entire project COPY . . + +# Move frontend files to the root +COPY --from=frontend /app/web ./web + +# Build the Go application RUN CGO_ENABLED=0 go build -o /bin/app . +# Stage 3: Create the final image FROM ubuntu:latest + +# Install dependencies for the final image RUN apt-get update && apt-get -y upgrade && apt-get install -y --no-install-recommends \ libssl-dev \ ca-certificates \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* + +# Copy the Go binary from the builder stage COPY --from=builder /bin/app /checkpointz + +# Expose port 5555 EXPOSE 5555 + +# Set the entrypoint for the container ENTRYPOINT ["/checkpointz"]