Skip to content

Commit

Permalink
try to fix build episode #1
Browse files Browse the repository at this point in the history
  • Loading branch information
sparkoo committed Dec 6, 2024
1 parent a5526ee commit c68b2c2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
34 changes: 11 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c68b2c2

Please sign in to comment.