-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDockerfile
More file actions
92 lines (77 loc) · 3.28 KB
/
Copy pathDockerfile
File metadata and controls
92 lines (77 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Multi-stage Dockerfile for the VS Code adblock extension monorepo.
# Dependencies are cached until package manifests / lockfile change.
# Each stage can be built independently via --target.
FROM adguard/node-ssh:22.22--0 AS base
SHELL ["/bin/bash", "-lc"]
WORKDIR /extension
# pnpm store directory — set once here, no need for pnpm config set in every RUN
ENV npm_config_store_dir=/pnpm-store
# ============================================================================
# Stage: deps
# Cached until package.json / workspace manifests / lockfile change
# ============================================================================
FROM base AS deps
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY client/package.json ./client/
COPY server/package.json ./server/
COPY shared/package.json ./shared/
COPY syntaxes/package.json ./syntaxes/
COPY tools/package.json ./tools/
COPY test/static/aglint/package.json ./test/static/aglint/
# --ignore-scripts: skips husky install (prepare script) which requires a git repo
RUN --mount=type=cache,target=/pnpm-store,id=vscode-adblock-pnpm \
pnpm install \
--frozen-lockfile \
--ignore-scripts \
--prefer-offline
# ============================================================================
# Stage: source
# Cached until source code changes
# ============================================================================
FROM deps AS source
COPY . /extension
# ============================================================================
# Stage: test-output
# Runs typecheck, lint, tests, and production build.
# Used as the CI validation target: `docker build --target test-output .`
# fails if any step fails.
# ============================================================================
FROM source AS test-output
RUN --mount=type=cache,target=/pnpm-store,id=vscode-adblock-pnpm \
pnpm --filter @vscode-adblock-syntax/shared build && \
pnpm test:compile && \
pnpm lint:md && \
pnpm lint:code && \
pnpm test && \
pnpm build
# ============================================================================
# Stage: build
# Builds the extension and packages a .vsix for publishing / release assets.
# ============================================================================
FROM source AS build
# Optional package version for local builds. CI injects the release version
# into package.json before building the image; locally this arg is required
# because package.json has no version field and vsce needs one.
ARG VERSION=""
# When true, package with `vsce package --pre-release` (Marketplace pre-release).
ARG PRE_RELEASE="false"
RUN --mount=type=cache,target=/pnpm-store,id=vscode-adblock-pnpm \
if [ -n "${VERSION}" ]; then npm pkg set version="${VERSION}"; fi && \
pnpm --filter @vscode-adblock-syntax/shared build && \
pnpm test:compile && \
pnpm lint:md && \
pnpm lint:code && \
pnpm test && \
pnpm build && \
if [ "${PRE_RELEASE}" = "true" ]; then \
pnpm package:pre; \
else \
pnpm package; \
fi && \
mkdir -p /out/artifacts && \
cp out/vscode-adblock.vsix /out/artifacts/ && \
if [ -f syntaxes/out/adblock.plist ]; then \
cp syntaxes/out/adblock.plist /out/artifacts/; \
fi
FROM scratch AS build-output
COPY --from=build /out/artifacts/ /