From 00fd75c57c44e8e78e37cf392e9e1f43ee505438 Mon Sep 17 00:00:00 2001 From: Imbus Date: Sun, 12 Nov 2023 06:43:37 +0100 Subject: [PATCH] Container related --- .containerignore | 4 ++++ container/Containerfile | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 .containerignore create mode 100644 container/Containerfile diff --git a/.containerignore b/.containerignore new file mode 100644 index 0000000..b5b7c6a --- /dev/null +++ b/.containerignore @@ -0,0 +1,4 @@ +**/target +**/node_modules +**/dist +**/.sqlite3 \ No newline at end of file diff --git a/container/Containerfile b/container/Containerfile new file mode 100644 index 0000000..d399b33 --- /dev/null +++ b/container/Containerfile @@ -0,0 +1,26 @@ +# 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 + +# 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"] \ No newline at end of file