Skip to content

Commit 6cc2d7a

Browse files
committed
add development docker container
1 parent 4acd71d commit 6cc2d7a

5 files changed

Lines changed: 82 additions & 11 deletions

File tree

‎.devcontainer/devcontainer.json‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "clangd in Browser",
3+
"build": {
4+
"dockerfile": "../Dockerfile",
5+
"context": ".."
6+
},
7+
"remoteUser": "node",
8+
"forwardPorts": [5173],
9+
"portsAttributes": {
10+
"5173": {
11+
"label": "Vite development server",
12+
"onAutoForward": "openBrowser"
13+
}
14+
},
15+
"mounts": [
16+
"source=clangd-web-node-modules,target=/workspace/node_modules,type=volume"
17+
],
18+
"postCreateCommand": "pnpm install --frozen-lockfile",
19+
"customizations": {
20+
"vscode": {
21+
"extensions": ["dbaeumer.vscode-eslint"]
22+
}
23+
}
24+
}

‎.dockerignore‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.git
2+
.github
3+
.agents
4+
.codex
5+
node_modules
6+
dist
7+
dist-ssr
8+
*.log
9+
*.local

‎.github/workflows/pages.yaml‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@ jobs:
2020
node-version: "22"
2121
cache: "pnpm"
2222
- run: pnpm install --frozen-lockfile
23-
- name: cache built clangd
24-
id: cache-build
25-
uses: actions/cache@v3
26-
with:
27-
path: ./public/wasm
28-
key: build-script-${{ hashFiles('build.sh') }}
29-
- if: ${{ steps.cache-build.outputs.cache-hit != 'true' }}
30-
name: build clangd
23+
# - name: cache built clangd
24+
# id: cache-build
25+
# uses: actions/cache@v3
26+
# with:
27+
# path: ./public/wasm
28+
# key: build-script-${{ hashFiles('build.sh') }}
29+
# - if: ${{ steps.cache-build.outputs.cache-hit != 'true' }}
30+
# name: build clangd
31+
# run: |
32+
# sudo apt update
33+
# sudo apt install vim git build-essential cmake ninja-build python3
34+
# ./build.sh
35+
- name: Get clangd wasm
3136
run: |
32-
sudo apt update
33-
sudo apt install vim git build-essential cmake ninja-build python3
34-
./build.sh
37+
curl --output public/wasm/clangd.wasm https://clangd.guyutongxue.site/wasm/clangd.wasm
38+
curl --output public/wasm/clangd.js https://clangd.guyutongxue.site/wasm/clangd.js
3539
- run: pnpm build
3640
- uses: actions/upload-pages-artifact@v3
3741
with:

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
26+
.pnpm-store

‎Dockerfile‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Shared development and CI image. The Node version matches package.json's Volta pin.
2+
FROM node:20.13.1-bookworm
3+
4+
ARG PNPM_VERSION=9.1.1
5+
6+
# Install pnpm with npm instead of using the Corepack shim bundled in Node.
7+
# Older Corepack releases fail while verifying pnpm's rotated signing key.
8+
# Keep this image focused on frontend development and testing. The separate
9+
# LLVM-to-Wasm toolchain in build.sh intentionally runs on the host/CI runner.
10+
RUN apt-get update \
11+
&& apt-get install --no-install-recommends --yes \
12+
ca-certificates \
13+
&& rm -rf /var/lib/apt/lists/* \
14+
&& corepack disable \
15+
&& npm install --global pnpm@${PNPM_VERSION} \
16+
&& pnpm --version
17+
18+
WORKDIR /workspace
19+
20+
# Install dependencies in the image so a container started without a bind
21+
# mount is immediately usable. A bind mount in development can reuse the
22+
# named node_modules volume declared by devcontainer.json.
23+
COPY --chown=node:node package.json pnpm-lock.yaml .npmrc ./
24+
RUN pnpm install --frozen-lockfile --prefer-offline
25+
26+
COPY --chown=node:node . .
27+
28+
ENV NODE_ENV=development
29+
EXPOSE 5173
30+
31+
USER node
32+
CMD ["pnpm", "dev", "--host", "0.0.0.0"]

0 commit comments

Comments
 (0)