Skip to content

Commit

Permalink
fix docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxkad committed Dec 16, 2023
1 parent eb1378d commit e411f59
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Expand Down
28 changes: 28 additions & 0 deletions src/dashboard/.dockerignore
Original file line number Diff line number Diff line change
@@ -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?
2 changes: 1 addition & 1 deletion src/dashboard/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default defineConfig(async ({ command, mode }) => {
},
},
mode: mode,
base: '/main',
base: '/dashboard',
build: {
minify: minify,
},
Expand Down

0 comments on commit e411f59

Please sign in to comment.