generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 33
Add Docker build system and containerized development environment #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-P ubuntu-latest=node:22-bookworm | ||
--container-options=--memory=32g --network=host |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Exclude large directories that aren't needed for build | ||
vscode/node_modules | ||
|
||
# Exclude build artifacts | ||
*.tar.gz | ||
*.log | ||
|
||
# Exclude development files | ||
.vscode/ | ||
.idea/ | ||
*.swp | ||
*.swo | ||
*~ | ||
|
||
# Exclude OS files | ||
.DS_Store | ||
Thumbs.db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.DS_Store | ||
.pc | ||
.pc | ||
.artifacts | ||
bin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
.PHONY: build-cache build install-act run-github run-local clean-vscode clean | ||
|
||
build-cache: | ||
@echo "Building SageMaker Code Editor (multi-stage npm cache)..." | ||
docker buildx build \ | ||
--platform linux/amd64 \ | ||
--progress=plain \ | ||
--memory=32g \ | ||
-t npm-cache:latest \ | ||
-f scripts/Dockerfile.build.cache . | ||
|
||
build: | ||
@echo "Building SageMaker Code Editor (original)..." | ||
docker buildx build \ | ||
--platform linux/amd64 \ | ||
--progress=plain \ | ||
--memory=32g \ | ||
--output type=local,dest=./.artifacts \ | ||
-t localbuild:latest \ | ||
-f scripts/Dockerfile.build . | ||
|
||
install-act: | ||
@echo "Installing act (GitHub Actions runner)..." | ||
@if ! command -v act >/dev/null 2>&1 && [ ! -f ./bin/act ]; then \ | ||
curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | bash; \ | ||
echo "act installed successfully"; \ | ||
else \ | ||
echo "act is already available"; \ | ||
fi | ||
|
||
run-github: install-act | ||
@echo "Running complete GitHub Actions workflow locally..." | ||
@echo "Available workflows:" | ||
@ls -la .github/workflows/ | ||
@echo "" | ||
@echo "Running full build.yml workflow..." | ||
@if command -v act >/dev/null 2>&1; then \ | ||
act push -W .github/workflows/build.yml --platform ubuntu-22.04=catthehacker/ubuntu:act-22.04 --container-options "--memory=32g --memory-swap=32g"; \ | ||
else \ | ||
./bin/act push -W .github/workflows/build.yml --platform ubuntu-22.04=catthehacker/ubuntu:act-22.04 --container-options "--memory=32g --memory-swap=32g"; \ | ||
fi | ||
|
||
run-local: | ||
@if [ -z "$(TARBALL)" ]; then \ | ||
echo "Building and running SageMaker Code Editor locally on port 8888..."; \ | ||
docker build -f scripts/Dockerfile.dev -t local-code-editor-dev . || exit 1; \ | ||
echo "Stopping container..."; \ | ||
aakashmandavilli96 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
docker stop local-code-editor-dev; \ | ||
sleep 2; \ | ||
echo "Starting container on http://localhost:8888"; \ | ||
docker run --rm -d -p 8888:8000 -v .:/workspace -u $(id -u):$(id -g) --entrypoint /workspace/scripts/run-code-editor-dev.sh --name local-code-editor-dev local-code-editor-dev || exit 1; \ | ||
docker logs -f local-code-editor-dev; \ | ||
else \ | ||
echo "Building and running SageMaker Code Editor locally on port 8888..."; \ | ||
docker build -f scripts/Dockerfile.run --build-arg TARBALL=$(TARBALL) -t local-code-editor . || exit 1; \ | ||
echo "Stopping container..."; \ | ||
docker stop local-code-editor; \ | ||
aakashmandavilli96 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sleep 2; \ | ||
echo "Starting container on http://localhost:8888"; \ | ||
docker run --rm -d -p 8888:8000 --name local-code-editor local-code-editor || exit 1; \ | ||
docker logs -f local-code-editor; \ | ||
fi | ||
|
||
clean-vscode: | ||
@echo "Cleaning VSCode node_modules..." | ||
@find . -type d -name "node_modules" -exec rm -rf {} + 2>/dev/null || true | ||
@rm -rf vscode/out/* 2>/dev/null || true | ||
@echo "VSCode cleanup completed" | ||
|
||
clean: clean-vscode | ||
@echo "Cleaning act temporary files and Docker images..." | ||
@echo "Removing act cache..." | ||
@rm -rf ~/.cache/act 2>/dev/null || true | ||
@echo "Act cleanup completed" | ||
|
||
reset-vscode: | ||
@echo "Resetting vscode submodule..." | ||
git submodule update --init --recursive | ||
git submodule foreach --recursive "git reset --hard HEAD && sudo git clean -fd" | ||
@echo "Resetting patches..." | ||
sudo rm -rf .pc/* | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM npm-cache:latest AS builder | ||
|
||
WORKDIR /workspace | ||
|
||
# Declare a build argument to control the minify flag | ||
ARG ARGS | ||
|
||
# Copy source files except vscode so new patches are picked up without cache busting | ||
COPY patches ./patches | ||
COPY resources ./resources | ||
COPY .git ./.git | ||
COPY scripts/ ./scripts/ | ||
COPY .pc ./.pc | ||
COPY LICENSE . | ||
COPY LICENSE-THIRD-PARTY . | ||
|
||
# Apply patches and build | ||
RUN chmod +x scripts/docker-install.sh && \ | ||
./scripts/docker-install.sh -t "$(cat vscode/package.json | grep '"version"' | cut -d'"' -f4)" | ||
|
||
RUN echo "Build arguments: $ARGS" | ||
RUN chmod +x scripts/create-code-editor-tarball.sh && \ | ||
./scripts/create-code-editor-tarball.sh -v "$(cat vscode/package.json | grep '"version"' | cut -d'"' -f4)" | ||
|
||
# Final stage: Minimal image with only the build artifacts to copy from | ||
FROM scratch | ||
COPY --from=builder /workspace/artifacts . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
FROM ubuntu:24.04 AS base-image | ||
|
||
# Install required tools and Node.js | ||
RUN apt-get update && apt-get install -y \ | ||
git \ | ||
python3 \ | ||
python3-pip \ | ||
build-essential \ | ||
curl \ | ||
quilt \ | ||
pkg-config \ | ||
libx11-dev \ | ||
libxkbfile-dev \ | ||
libsecret-1-dev \ | ||
libkrb5-dev \ | ||
libgssapi-krb5-2 \ | ||
time \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install Node.js 22 (latest LTS) | ||
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ | ||
apt-get install -y nodejs | ||
|
||
# Stage 2: NPM Dependencies Cache | ||
# This stage uses the pre-configured base-image to build the cache. | ||
FROM base-image AS npm-cache | ||
|
||
WORKDIR /workspace | ||
|
||
COPY vscode ./vscode | ||
COPY patches ./patches | ||
COPY resources ./resources | ||
COPY .git ./.git | ||
COPY scripts/postinstall.sh ./scripts/postinstall.sh | ||
arkaprava08 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
COPY scripts/docker-install.sh ./scripts/docker-install.sh | ||
COPY scripts/copy-resources.sh ./scripts/copy-resources.sh | ||
COPY .pc ./.pc | ||
COPY LICENSE . | ||
COPY LICENSE-THIRD-PARTY . | ||
|
||
# Apply patches and build | ||
RUN chmod +x scripts/docker-install.sh && \ | ||
./scripts/docker-install.sh -t "$(cat vscode/package.json | grep '"version"' | cut -d'"' -f4)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
FROM ubuntu:24.04 AS base-image | ||
|
||
# Install required tools and Node.js | ||
RUN apt-get update && apt-get install -y \ | ||
git \ | ||
python3 \ | ||
python3-pip \ | ||
build-essential \ | ||
curl \ | ||
quilt \ | ||
pkg-config \ | ||
libx11-dev \ | ||
libxkbfile-dev \ | ||
libsecret-1-dev \ | ||
libkrb5-dev \ | ||
libgssapi-krb5-2 \ | ||
time \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install Node.js 22 (latest LTS) | ||
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ | ||
apt-get install -y nodejs | ||
|
||
# Stage 2: NPM Dependencies Cache | ||
# This stage uses the pre-configured base-image to build the cache. | ||
FROM base-image AS npm-cache | ||
|
||
# Install supervisord | ||
RUN apt-get update && \ | ||
apt-get install -y supervisor | ||
|
||
WORKDIR /workspace | ||
|
||
EXPOSE 8080 | ||
|
||
# Following is the entrypoint script for local runs: /workspace/scripts/run-code-editor-dev.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM public.ecr.aws/sagemaker/sagemaker-distribution:latest-cpu | ||
|
||
# Accept tarball name as build argument | ||
ARG TARBALL=code-editor1.8.0b5.tar.gz | ||
|
||
# Switch to root to install | ||
USER root | ||
|
||
# Copy and extract the code editor to /tmp | ||
COPY .artifacts/${TARBALL} /tmp/ | ||
RUN cd /tmp && tar -xzf ${TARBALL} | ||
|
||
# Move to final location and set permissions | ||
RUN mv /tmp/sagemaker-code-editor /opt/ && \ | ||
chmod +x /opt/sagemaker-code-editor/bin/code-server-oss | ||
|
||
# Add to PATH | ||
ENV PATH="/opt/sagemaker-code-editor/bin:$PATH" | ||
|
||
# Expose port | ||
EXPOSE 8000 | ||
|
||
# Run code-server-oss with host binding to all interfaces | ||
CMD ["code-server-oss", "--host", "0.0.0.0", "--without-connection-token"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.