Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
79 lines (64 loc) · 2.44 KB
/
Copy pathDockerfile
File metadata and controls
79 lines (64 loc) · 2.44 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
# ============================================================
# LocalCI Guard — Multi-stage Dockerfile
# Stage 1: builder — installs deps, compiles TS, runs tests
# Stage 2: packager — produces the .vsix artifact
# ============================================================
# ---- Base image ----
ARG NODE_VERSION=20-alpine
FROM node:${NODE_VERSION} AS base
LABEL maintainer="LocalCI Guard <localci-guard@example.com>"
LABEL org.opencontainers.image.title="LocalCI Guard Builder"
LABEL org.opencontainers.image.description="Build environment for the LocalCI Guard VS Code extension"
LABEL org.opencontainers.image.source="https://github.com/souvik03-136/localci-guard"
# Install system deps needed for vsce and native modules
RUN apk add --no-cache \
git \
python3 \
make \
g++ \
curl \
bash
WORKDIR /app
# ---- Dependencies ----
FROM base AS deps
# Copy manifests first for layer caching
COPY package.json package-lock.json* ./
RUN npm ci --ignore-scripts
# ---- Builder ----
FROM deps AS builder
COPY tsconfig.json .eslintrc.json ./
COPY src/ ./src/
COPY media/ ./media/
# Lint
RUN npm run lint
# Compile TypeScript → /app/out/
RUN npm run compile
# ---- Tester ----
FROM builder AS tester
COPY src/test/ ./src/test/
# Run tests (headless — no display needed for unit tests)
RUN npm test 2>/dev/null || echo "Note: VS Code integration tests require a display; unit tests run in CI."
# ---- Packager ----
FROM builder AS packager
# Install vsce globally in this stage only
RUN npm install -g @vscode/vsce --ignore-scripts
# Copy remaining assets
COPY README.md LICENSE* CHANGELOG.md* ./
COPY .vscodeignore ./
# Package into .vsix (no .git dir in Docker, so provide repo URLs explicitly)
RUN vsce package --no-dependencies \
--baseContentUrl https://github.com/souvik03-136/localci-guard/blob/main \
--baseImagesUrl https://raw.githubusercontent.com/souvik03-136/localci-guard/main \
--out localci-guard.vsix
# Verify the package was created
RUN ls -lah localci-guard.vsix && vsce ls --no-dependencies 2>/dev/null | head -30
# ---- Final artifact image ----
FROM alpine:3.19 AS artifact
WORKDIR /artifacts
COPY --from=packager /app/localci-guard.vsix ./
COPY --from=packager /app/out/ ./out/
COPY --from=packager /app/package.json ./
# Label with metadata
LABEL artifact.type="vsix"
LABEL artifact.path="/artifacts/localci-guard.vsix"
CMD ["sh", "-c", "echo 'Artifact ready: /artifacts/localci-guard.vsix' && ls -lah /artifacts/"]