diff --git a/Dockerfile b/Dockerfile index 99b9d545..e9ff70b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,18 @@ ARG GO_VERSION=1.21 ARG REPO=github.com/LiterMC/go-openbmclapi +ARG NPM_DIR=src/dashboard + +FROM node:21 AS WEB_BUILD + +ARG NPM_DIR + +WORKDIR /web/ +COPY ["${NPM_DIR}/package.json", "${NPM_DIR}/package-lock.json", "/web/"] +RUN --mount=type=cache,target=/root/.npm/_cacache \ + npm ci --progress=false || { cat /root/.npm/_logs/*; exit 1; } +COPY ["${NPM_DIR}", "/web/"] +RUN npm run build || { cat /root/.npm/_logs/*; exit 1; } FROM golang:${GO_VERSION}-alpine AS BUILD @@ -10,6 +22,7 @@ ARG TAG COPY ./go.mod ./go.sum "/go/src/${REPO}/" COPY ./src "/go/src/${REPO}/src" +COPY --from=WEB_BUILD "/web/dist" "/go/src/${REPO}/${NPM_DIR}/dist" RUN --mount=type=cache,target=/root/.cache/go-build cd "/go/src/${REPO}" && \ CGO_ENABLED=0 go build -v -o "/go/bin/application" -ldflags="-X 'main.BuildVersion=${TAG}'" "./src" diff --git a/src/dashboard/.dockerignore b/src/dashboard/.dockerignore new file mode 100644 index 00000000..38adffa6 --- /dev/null +++ b/src/dashboard/.dockerignore @@ -0,0 +1,28 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +.DS_Store +dist +dist-ssr +coverage +*.local + +/cypress/videos/ +/cypress/screenshots/ + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/src/dashboard/vite.config.ts b/src/dashboard/vite.config.ts index c3cec6df..6980898b 100644 --- a/src/dashboard/vite.config.ts +++ b/src/dashboard/vite.config.ts @@ -17,7 +17,7 @@ export default defineConfig(async ({ command, mode }) => { }, }, mode: mode, - base: '/main', + base: '/dashboard', build: { minify: minify, },