Skip to content

Commit 31df0b7

Browse files
author
Arkaprava De
committed
Add Docker build system and containerized development environment
- Add Docker build configurations for development and production - Add Makefile for simplified build commands - Add GitHub Actions cache support for Docker builds - Add .actrc for local GitHub Actions testing - Add .dockerignore for optimized Docker builds - Add scripts for Docker-based installation and tarball creation - Remove old tarball creation script
1 parent c36a732 commit 31df0b7

15 files changed

+350
-56
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: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ jobs:
2121

2222
run-unit-tests:
2323
name: Run unit tests
24-
runs-on: ubuntu-latest
24+
runs-on: ubuntu-22.04
2525
steps:
2626
# Checkout repository code
2727
- name: Checkout code
2828
uses: actions/checkout@v4
2929

3030
# Verify CSP line exists in target TypeScript file
3131
- name: Check CSP configuration in webClientServer.ts
32+
shell: sh
3233
run: |
3334
TARGET_FILE="patched-vscode/src/vs/server/node/webClientServer.ts"
3435
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;'"
@@ -50,10 +51,10 @@ jobs:
5051
# The main job for building the application
5152
build:
5253
name: Build sagemaker-code-editor
53-
runs-on: ubuntu-latest
54+
runs-on: ubuntu-22.04
5455
# Ensure unit tests pass before building
5556
needs: run-unit-tests
56-
timeout-minutes: 180
57+
timeout-minutes: 60
5758
env:
5859
# Environment variable to optimize the build process
5960
DISABLE_V8_COMPILE_CACHE: 1
@@ -104,24 +105,17 @@ jobs:
104105
cd vscode
105106
export DISABLE_V8_COMPILE_CACHE=1
106107
export UV_THREADPOOL_SIZE=4
108+
109+
npm install -g node-gyp
107110
108-
# Install dependencies using npm
109-
npm install
110-
111-
# The logic for temporarily removing and re-adding ripgrep remains
112-
VSCODE_RIPGREP_VERSION=$(jq -r '.dependencies."@vscode/ripgrep"' package.json)
113-
mv package.json package.json.orig
114-
jq 'del(.dependencies."@vscode/ripgrep")' package.json.orig > package.json
115-
116-
# Re-run install to remove ripgrep
111+
# Install dependencies using npm, skip optional and native modules
117112
npm install
118113
119-
# Add ripgrep back using npm
120-
npm install --ignore-scripts "@vscode/ripgrep@${VSCODE_RIPGREP_VERSION}"
121-
114+
# Run the gulp build task with memory optimizations
122115
ARCH_ALIAS=linux-x64
123-
# Run the gulp build task using npx
124-
npx gulp vscode-reh-web-${ARCH_ALIAS}-min
116+
node --max-old-space-size=32768 --optimize-for-size \
117+
./node_modules/gulp/bin/gulp.js \
118+
"vscode-reh-web-${ARCH_ALIAS}-min"
125119
126120
# Step 7: Find the exact path of the original build output directory.
127121
- name: Find build output
@@ -157,14 +151,15 @@ jobs:
157151
158152
# Step 10: Upload the tarball as a build artifact.
159153
- name: Upload build artifact
154+
if: env.ACT == ''
160155
uses: actions/upload-artifact@v4
161156
with:
162157
name: npm-package
163158
path: sagemaker-code-editor-${{ env.VERSION }}.tar.gz
164159
# Run end-to-end tests after the build is complete
165160
run-e2e-tests:
166161
name: Run e2e tests
167-
runs-on: ubuntu-latest
162+
runs-on: ubuntu-22.04
168163
needs: build # Ensure e2e tests run after build
169164
steps:
170165
# Checkout repository code

Makefile

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 "Usage: make run-local TARBALL=<tarball-name>"; \
44+
echo "Example: make run-local TARBALL=code-editor1.8.0b5.tar.gz"; \
45+
exit 1; \
46+
fi
47+
@echo "Building and running SageMaker Code Editor locally on port 8888..."
48+
docker build -f scripts/Dockerfile.run --build-arg TARBALL=$(TARBALL) -t local-code-editor .
49+
docker stop local-code-editor 2>/dev/null || true
50+
@echo "Starting container on http://localhost:8888"
51+
docker run --rm -d -p 8888:8000 --name local-code-editor local-code-editor
52+
docker logs -f local-code-editor
53+
54+
clean:
55+
@echo "Cleaning build artifacts..."
56+
rm -f artifacts
57+
@echo "Clean build artifacts completed"
58+
@echo "Cleaning act temporary files and Docker images..."
59+
@echo "Removing act cache..."
60+
@rm -rf ~/.cache/act 2>/dev/null || true
61+
@echo "Act cleanup completed"
62+

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ 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 TARBALL=<tarball-name>` - Build and run SageMaker Code Editor locally on port 8888 using specified tarball
40+
- `make clean` - Clean build artifacts and act temporary files
41+
42+
Example: `make run-local TARBALL=code-editor1.8.0b5.tar.gz`
43+
3144
## Troubleshooting and Feedback
3245

3346
For any issues that customers would like to report, please route to the `amazon-sagemaker-feedback` repository: https://github.com/aws/amazon-sagemaker-feedback
62.8 MB
Binary file not shown.
62.8 MB
Binary file not shown.

bin/act

19.9 MB
Binary file not shown.

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 "ARKA 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)"

0 commit comments

Comments
 (0)