Skip to content

Commit

Permalink
Update Dockerfile
Browse files Browse the repository at this point in the history
Signed-off-by: Atif Ather <[email protected]>
  • Loading branch information
atifather authored Dec 14, 2023
1 parent daf3cbe commit b77de4e
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,29 @@
FROM node:18 AS frontend

# Set the working directory for the frontend
WORKDIR /web
WORKDIR /app/web

# Copy only the necessary files for the frontend build
COPY ./web /web
COPY ./web/package.json ./web/package-lock.json ./
COPY ./web/Makefile ./
COPY ./web/src ./src

# 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 /web
# Build the frontend
RUN make build-web

# Switch back to the root directory
WORKDIR /app

# Copy the entire project with the built frontend
COPY . .

# Stage 2: Build the Go application
FROM golang:1.20 AS builder

# Set the working directory for Go application
# Set the working directory for the Go application
WORKDIR /src

# Copy Go modules files
Expand All @@ -26,11 +33,8 @@ COPY go.sum go.mod ./
# Download Go modules
RUN go mod download

# Copy the entire project
COPY . .

# Copy the built frontend assets from the frontend stage
COPY --from=frontend /web/build /web/build
# Copy the entire project from the first stage
COPY --from=frontend /app .

# Build the Go application
RUN CGO_ENABLED=0 go build -o /bin/app .
Expand Down

0 comments on commit b77de4e

Please sign in to comment.