From c68b2c2902261cef3fd6a73bf4665ce2f817336c Mon Sep 17 00:00:00 2001 From: Michal Vala Date: Fri, 6 Dec 2024 06:39:53 +0100 Subject: [PATCH] try to fix build episode #1 --- Dockerfile | 34 +++++++++++----------------------- main.go | 4 ++-- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3f0d652..93b2304 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM golang:1.21 as builderGo +# backend build +FROM golang:1.23 as builderGo USER root WORKDIR /csgo-2d-demo-player @@ -14,43 +15,30 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build \ -asmflags all=-trimpath=/ \ main.go - +# web build FROM node:lts-slim as builderNpm USER root -# index build -WORKDIR /csgo-2d-demo-player/index +WORKDIR /csgo-2d-demo-player/web -COPY web/index/package.json . -COPY web/index/package-lock.json . +COPY web/package.json . +COPY web/package-lock.json . RUN npm install -COPY web/index/.env.production . -COPY web/index/public public -COPY web/index/src src +COPY web/.env.production . +COPY web/public public +COPY web/src src RUN npm run build -# player build -WORKDIR /csgo-2d-demo-player/player - -COPY web/player/package.json . -COPY web/player/package-lock.json . -RUN npm install - -COPY web/player/public public -COPY web/player/src src -RUN npm run build - - +# dist FROM debian:buster-slim RUN apt-get update && apt-get install -y ca-certificates COPY --from=builderGo /csgo-2d-demo-player/_output/main /csgo-2d-demo-player/ COPY --from=builderGo /csgo-2d-demo-player/assets/ /csgo-2d-demo-player/assets/ -COPY --from=builderNpm /csgo-2d-demo-player/player/build/ /csgo-2d-demo-player/web/player/build/ -COPY --from=builderNpm /csgo-2d-demo-player/index/build/ /csgo-2d-demo-player/web/index/build/ +COPY --from=builderNpm /csgo-2d-demo-player/web/dist/ /csgo-2d-demo-player/web/dist/ WORKDIR /csgo-2d-demo-player diff --git a/main.go b/main.go index 686ec8c..16e3ddd 100644 --- a/main.go +++ b/main.go @@ -72,8 +72,8 @@ func server(ctx context.Context) { } http.ServeFile(w, r, "./wasm/main.wasm") }) - mux.Handle("/", http.FileServer(http.Dir("web/index/build"))) - mux.Handle("/player/", http.StripPrefix("/player", http.FileServer(http.Dir("web/player/build")))) + mux.Handle("/", http.FileServer(http.Dir("web/dist"))) + // mux.Handle("/player/", http.StripPrefix("/player", http.FileServer(http.Dir("web/player/build")))) listService, listServiceErr := list.NewListService(ctx, config) if listServiceErr != nil {