Skip to content

Commit 0deec82

Browse files
author
Arkaprava De
committed
Update changes
1 parent e1451a8 commit 0deec82

16 files changed

+495
-48
lines changed

.actrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-P ubuntu-latest=node:22-bookworm
2+
--container-options=--memory=32g --network=host

.dockerignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Exclude large directories that aren't needed for build
2+
vscode/node_modules
3+
4+
# Exclude build artifacts
5+
*.tar.gz
6+
*.log
7+
8+
# Exclude development files
9+
.vscode/
10+
.idea/
11+
*.swp
12+
*.swo
13+
*~
14+
15+
# Exclude OS files
16+
.DS_Store
17+
Thumbs.db

.github/workflows/build.yml

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,43 @@ concurrency:
99
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
1010

1111
jobs:
12+
# Run unit tests before building the application
13+
14+
run-unit-tests:
15+
name: Run unit tests
16+
runs-on: ubuntu-22.04
17+
steps:
18+
# Checkout repository code
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
# Verify CSP line exists in target TypeScript file
23+
- name: Check CSP configuration in webClientServer.ts
24+
shell: sh
25+
run: |
26+
TARGET_FILE="patched-vscode/src/vs/server/node/webClientServer.ts"
27+
REQUIRED_TEXT="'connect-src \'self\' ws: wss: https://main.vscode-cdn.net http://localhost:* https://localhost:* https://login.microsoftonline.com/ https://update.code.visualstudio.com https://*.vscode-unpkg.net/ https://default.exp-tas.com/vscode/ab https://vscode-sync.trafficmanager.net https://vscode-sync-insiders.trafficmanager.net https://*.gallerycdn.vsassets.io https://marketplace.visualstudio.com https://openvsxorg.blob.core.windows.net https://az764295.vo.msecnd.net https://code.visualstudio.com https://*.gallery.vsassets.io https://*.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com https://*.servicebus.windows.net/ https://vscode.blob.core.windows.net https://vscode.search.windows.net https://vsmarketplacebadges.dev https://vscode.download.prss.microsoft.com https://download.visualstudio.microsoft.com https://*.vscode-unpkg.net https://open-vsx.org;'"
28+
29+
if [ ! -f "$TARGET_FILE" ]; then
30+
echo "❌ FAIL: Target file $TARGET_FILE does not exist."
31+
exit 1
32+
fi
33+
34+
if grep -F "$REQUIRED_TEXT" "$TARGET_FILE" > /dev/null; then
35+
echo "✅ PASS: Required CSP text exists."
36+
else
37+
echo "❌ FAIL: Required CSP text NOT found in $TARGET_FILE"
38+
exit 1
39+
fi
40+
41+
42+
43+
# The main job for building the application
1244
build:
1345
name: Build sagemaker-code-editor
14-
runs-on: ubuntu-latest
46+
runs-on: ubuntu-22.04
47+
# Ensure unit tests pass before building
48+
needs: run-unit-tests
1549
timeout-minutes: 180
1650
env:
1751
DISABLE_V8_COMPILE_CACHE: 1
@@ -53,18 +87,17 @@ jobs:
5387
cd vscode
5488
export DISABLE_V8_COMPILE_CACHE=1
5589
export UV_THREADPOOL_SIZE=4
90+
91+
npm install -g node-gyp
5692
93+
# Install dependencies using npm, skip optional and native modules
5794
npm install
5895
59-
VSCODE_RIPGREP_VERSION=$(jq -r '.dependencies."@vscode/ripgrep"' package.json)
60-
mv package.json package.json.orig
61-
jq 'del(.dependencies."@vscode/ripgrep")' package.json.orig > package.json
62-
63-
npm install
64-
npm install --ignore-scripts "@vscode/ripgrep@${VSCODE_RIPGREP_VERSION}"
65-
96+
# Run the gulp build task with memory optimizations
6697
ARCH_ALIAS=linux-x64
67-
npx gulp vscode-reh-web-${ARCH_ALIAS}-min
98+
node --max-old-space-size=32768 --optimize-for-size \
99+
./node_modules/gulp/bin/gulp.js \
100+
"vscode-reh-web-${ARCH_ALIAS}-min"
68101
69102
- name: Find build output
70103
id: find_output
@@ -96,7 +129,23 @@ jobs:
96129
tar czf $TARBALL -C "$PARENT_DIR" "$BUILD_DIR_NAME"
97130
98131
- name: Upload build artifact
132+
if: env.ACT == ''
99133
uses: actions/upload-artifact@v4
100134
with:
101135
name: npm-package
102136
path: sagemaker-code-editor-${{ env.VERSION }}.tar.gz
137+
# Run end-to-end tests after the build is complete
138+
run-e2e-tests:
139+
name: Run e2e tests
140+
permissions:
141+
contents: read
142+
runs-on: ubuntu-22.04
143+
needs: build # Ensure e2e tests run after build
144+
steps:
145+
# Checkout repository code
146+
- name: Checkout code
147+
uses: actions/checkout@v4
148+
149+
# Output placeholder message for e2e tests
150+
- name: Test of e2e test
151+
run: echo "Test of e2e test"

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.DS_Store
2-
.pc
2+
.pc
3+
.artifacts
4+
bin

Makefile

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
.PHONY: build-cache build install-act run-github run-local clean
2+
3+
build-cache:
4+
@echo "Building SageMaker Code Editor (multi-stage npm cache)..."
5+
docker buildx build \
6+
--progress=plain \
7+
--memory=32g \
8+
-t npm-cache:latest \
9+
-f scripts/Dockerfile.build.cache .
10+
11+
build:
12+
@echo "Building SageMaker Code Editor (original)..."
13+
docker buildx build \
14+
--progress=plain \
15+
--memory=32g \
16+
--output type=local,dest=./.artifacts \
17+
-t localbuild:latest \
18+
-f scripts/Dockerfile.build .
19+
20+
install-act:
21+
@echo "Installing act (GitHub Actions runner)..."
22+
@if ! command -v act >/dev/null 2>&1 && [ ! -f ./bin/act ]; then \
23+
curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | bash; \
24+
echo "act installed successfully"; \
25+
else \
26+
echo "act is already available"; \
27+
fi
28+
29+
run-github: install-act
30+
@echo "Running complete GitHub Actions workflow locally..."
31+
@echo "Available workflows:"
32+
@ls -la .github/workflows/
33+
@echo ""
34+
@echo "Running full build.yml workflow..."
35+
@if command -v act >/dev/null 2>&1; then \
36+
act push -W .github/workflows/build.yml --platform ubuntu-22.04=catthehacker/ubuntu:act-22.04 --container-options "--memory=32g --memory-swap=32g"; \
37+
else \
38+
./bin/act push -W .github/workflows/build.yml --platform ubuntu-22.04=catthehacker/ubuntu:act-22.04 --container-options "--memory=32g --memory-swap=32g"; \
39+
fi
40+
41+
run-local:
42+
@if [ -z "$(TARBALL)" ]; then \
43+
echo "Building and running SageMaker Code Editor locally on port 8888..."; \
44+
docker build -f scripts/Dockerfile.dev -t local-code-editor-dev . || exit 1; \
45+
echo "Stopping container..."; \
46+
docker stop local-code-editor-dev; \
47+
sleep 2; \
48+
echo "Starting container on http://localhost:8888"; \
49+
docker run --rm -d -p 8888:8000 -v .:/workspace --entrypoint /workspace/scripts/run-code-editor-dev.sh --name local-code-editor-dev local-code-editor-dev || exit 1; \
50+
docker logs -f local-code-editor-dev; \
51+
else \
52+
echo "Building and running SageMaker Code Editor locally on port 8888..."; \
53+
docker build -f scripts/Dockerfile.run --build-arg TARBALL=$(TARBALL) -t local-code-editor . || exit 1; \
54+
echo "Stopping container..."; \
55+
docker stop local-code-editor; \
56+
echo "Starting container on http://localhost:8888"; \
57+
docker run --rm -d -p 8888:8000 --name local-code-editor local-code-editor || exit 1; \
58+
docker logs -f local-code-editor; \
59+
fi
60+
61+
clean-vscode:
62+
@echo "Cleaning VSCode node_modules..."
63+
@find . -type d -name "node_modules" -exec rm -rf {} + 2>/dev/null || true
64+
@rm -rf vscode/out/* 2>/dev/null || true
65+
@echo "VSCode cleanup completed"
66+
67+
clean:
68+
@echo "Clean build artifacts completed"
69+
@echo "Cleaning act temporary files and Docker images..."
70+
@echo "Removing act cache..."
71+
@rm -rf ~/.cache/act 2>/dev/null || true
72+
@echo "Act cleanup completed"
73+

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ This script will:
2828
- Run `yarn watch` from within the `vscode` folder
2929
- Open a new terminal and run `./vscode/scripts/code-server.sh --launch`
3030

31+
## Make Commands
32+
33+
Available make targets for building and testing:
34+
35+
- `make build-cache` - Build SageMaker Code Editor with multi-stage npm cache
36+
- `make build` - Build SageMaker Code Editor and output artifacts to ./artifacts
37+
- `make install-act` - Install act (GitHub Actions runner) for local testing
38+
- `make run-github` - Run complete GitHub Actions workflow locally using act
39+
- `make run-local` - Build and run SageMaker Code Editor locally on port 8888 from source
40+
- `make run-local TARBALL=<tarball-name>` - Build and run SageMaker Code Editor locally on port 8888 using specified tarball
41+
- `make clean` - Clean build artifacts and act temporary files
42+
43+
Example: `make run-local TARBALL=sagemaker-code-editor-1.101.2.tar.gz`
44+
3145
## Troubleshooting and Feedback
3246

3347
For any issues that customers would like to report, please route to the `amazon-sagemaker-feedback` repository: https://github.com/aws/amazon-sagemaker-feedback

scripts/Dockerfile.build

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM npm-cache:latest AS builder
2+
3+
WORKDIR /workspace
4+
5+
# Declare a build argument to control the minify flag
6+
ARG ARGS
7+
8+
# Apply patches and build
9+
COPY scripts/create-code-editor-tarball.sh ./scripts/create-code-editor-tarball.sh
10+
11+
RUN echo "Build arguments: $ARGS"
12+
RUN chmod +x scripts/create-code-editor-tarball.sh && \
13+
./scripts/create-code-editor-tarball.sh -v "$(cat vscode/package.json | grep '"version"' | cut -d'"' -f4)"
14+
15+
# Final stage: Minimal image with only the build artifacts to copy from
16+
FROM scratch
17+
COPY --from=builder /workspace/artifacts .

scripts/Dockerfile.build.cache

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM ubuntu:24.04 AS base-image
2+
3+
# Install required tools and Node.js
4+
RUN apt-get update && apt-get install -y \
5+
git \
6+
python3 \
7+
python3-pip \
8+
build-essential \
9+
curl \
10+
quilt \
11+
pkg-config \
12+
libx11-dev \
13+
libxkbfile-dev \
14+
libsecret-1-dev \
15+
libkrb5-dev \
16+
libgssapi-krb5-2 \
17+
time \
18+
&& rm -rf /var/lib/apt/lists/*
19+
20+
# Install Node.js 22 (latest LTS)
21+
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
22+
apt-get install -y nodejs
23+
24+
# Stage 2: NPM Dependencies Cache
25+
# This stage uses the pre-configured base-image to build the cache.
26+
FROM base-image AS npm-cache
27+
28+
WORKDIR /workspace
29+
30+
# Copy all package.json and package-lock.json using BuildKit glob
31+
COPY vscode ./vscode
32+
COPY patches ./patches
33+
COPY resources ./resources
34+
COPY .git ./.git
35+
COPY scripts/postinstall.sh ./scripts/postinstall.sh
36+
COPY scripts/docker-install.sh ./scripts/docker-install.sh
37+
COPY scripts/copy-resources.sh ./scripts/copy-resources.sh
38+
COPY LICENSE .
39+
COPY LICENSE-THIRD-PARTY .
40+
41+
# Apply patches and build
42+
RUN chmod +x scripts/docker-install.sh && \
43+
./scripts/docker-install.sh -t "$(cat vscode/package.json | grep '"version"' | cut -d'"' -f4)"

scripts/Dockerfile.dev

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM npm-cache:latest
2+
3+
# Install supervisord
4+
RUN apt-get update && \
5+
apt-get install -y supervisor
6+
7+
WORKDIR /workspace
8+
9+
EXPOSE 8080
10+
11+
# ENTRYPOINT [ "/workspace/scripts/run-code-editor-dev.sh" ]

scripts/Dockerfile.run

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM public.ecr.aws/sagemaker/sagemaker-distribution:latest-cpu
2+
3+
# Accept tarball name as build argument
4+
ARG TARBALL=code-editor1.8.0b5.tar.gz
5+
6+
# Switch to root to install
7+
USER root
8+
9+
# Copy and extract the code editor to /tmp
10+
COPY .artifacts/${TARBALL} /tmp/
11+
RUN cd /tmp && tar -xzf ${TARBALL}
12+
13+
# Move to final location and set permissions
14+
RUN mv /tmp/sagemaker-code-editor /opt/ && \
15+
chmod +x /opt/sagemaker-code-editor/bin/code-server-oss
16+
17+
# Add to PATH
18+
ENV PATH="/opt/sagemaker-code-editor/bin:$PATH"
19+
20+
# Expose port
21+
EXPOSE 8000
22+
23+
# Run code-server-oss with host binding to all interfaces
24+
CMD ["code-server-oss", "--host", "0.0.0.0", "--without-connection-token"]

0 commit comments

Comments
 (0)