2023-11-12 06:43:37 +01:00
|
|
|
# Client/frontend build in an isolated stage
|
|
|
|
# We use node:latest as the base image.
|
|
|
|
# Essentially we build the frontend SPA with vite and
|
|
|
|
# make it available in the public directory.
|
|
|
|
FROM docker.io/node:latest as client
|
|
|
|
WORKDIR /build
|
|
|
|
ADD client /build
|
|
|
|
RUN npm install
|
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
# Builds the server in an isolated stage
|
|
|
|
FROM docker.io/golang:latest as go
|
|
|
|
ADD server /build
|
|
|
|
WORKDIR /build
|
|
|
|
|
|
|
|
# Copy the frontend SPA build into public
|
|
|
|
# COPY --from=client /build/dist /runner/public
|
|
|
|
COPY --from=client /build/dist /build/static
|
|
|
|
|
2024-02-11 17:13:27 +01:00
|
|
|
# Get the dependencies
|
|
|
|
RUN go mod download
|
|
|
|
|
2023-11-12 06:43:37 +01:00
|
|
|
# RUN go build -o server
|
|
|
|
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o server
|
|
|
|
|
|
|
|
EXPOSE 8080
|
|
|
|
|
|
|
|
# Run the server
|
|
|
|
CMD ["./server"]
|