mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-04 12:36:37 +08:00
Improve Docker build caching
This commit is contained in:
@@ -45,6 +45,8 @@ password.*
|
|||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
.workbuddy/
|
.workbuddy/
|
||||||
|
.dev-cache/
|
||||||
|
.dev-data/
|
||||||
node_modules/
|
node_modules/
|
||||||
**/node_modules/
|
**/node_modules/
|
||||||
web/dist/
|
web/dist/
|
||||||
|
|||||||
+6
-3
@@ -19,7 +19,8 @@ FROM --platform=$BUILDPLATFORM node:20-alpine AS frontend
|
|||||||
ARG NPM_CONFIG_REGISTRY=https://registry.npmjs.org/
|
ARG NPM_CONFIG_REGISTRY=https://registry.npmjs.org/
|
||||||
WORKDIR /app/web
|
WORKDIR /app/web
|
||||||
COPY web/package*.json ./
|
COPY web/package*.json ./
|
||||||
RUN npm ci --registry="${NPM_CONFIG_REGISTRY}"
|
RUN --mount=type=cache,target=/root/.npm \
|
||||||
|
npm ci --registry="${NPM_CONFIG_REGISTRY}"
|
||||||
COPY web/ .
|
COPY web/ .
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
@@ -31,10 +32,12 @@ ARG GOPROXY=https://proxy.golang.org,direct
|
|||||||
ENV GOPROXY=${GOPROXY}
|
ENV GOPROXY=${GOPROXY}
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||||
|
go mod download
|
||||||
COPY . .
|
COPY . .
|
||||||
COPY --from=frontend /app/web/dist ./web/dist
|
COPY --from=frontend /app/web/dist ./web/dist
|
||||||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||||
|
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
|
||||||
go build -trimpath -ldflags="-s -w" -o mediastation-go ./cmd/server
|
go build -trimpath -ldflags="-s -w" -o mediastation-go ./cmd/server
|
||||||
|
|
||||||
# ---- Stage 3: runtime ------------------------------------------------------
|
# ---- Stage 3: runtime ------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user