From 7d2e7e64f02db79af84cda9396831cbfcb13910c Mon Sep 17 00:00:00 2001 From: sireesha Date: Fri, 4 Jul 2025 13:22:55 +0530 Subject: [PATCH 1/4] testing post create script --- .devcontainer/devcontainer.json | 44 +++++++++++------------------ .devcontainer/scripts/postCreate.sh | 5 +++- .github/workflows/post-create.yml | 42 +++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/post-create.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e629bb760..42eafee90 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,37 +1,25 @@ -// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.117.1/containers/go { - "name": "devcontainers-ci", - "dockerFile": "Dockerfile", + "name": "Test CI/CD Project", "build": { - "cacheFrom": "ghcr.io/devcontainers/ci-devcontainer:latest" + "dockerfile": "Dockerfile" }, - "mounts": [ - // Keep command history - "source=devcontainer-build-run-bashhistory,target=/home/vscode/commandhistory", - // Mount host docker socket - "type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock" - ], - "postCreateCommand": ".devcontainer/scripts/postCreate.sh", - "remoteUser": "vscode", + "features": { + "ghcr.io/devcontainers/features/git:1": { + "version": "latest" + } + }, + "postCreateCommand": "chmod +x scripts/*.sh && scripts/post-create.sh", + "postStartCommand": "chmod +x scripts/*.sh && scripts/post-start.sh", "customizations": { "vscode": { - "settings": { - "terminal.integrated.defaultProfile.linux": "bash", - "files.eol": "\n" - }, "extensions": [ - "ms-azuretools.vscode-docker", - "yzhang.markdown-all-in-one", - "davidanson.vscode-markdownlint", - "heaths.vscode-guid", - "esbenp.prettier-vscode", - "meganrogge.template-string-converter", - "ms-azure-devops.azure-pipelines" - ] + "ms-azuretools.vscode-docker" + ], + "settings": { + "terminal.integrated.defaultProfile.linux": "bash" + } } }, - "features": { - "ghcr.io/devcontainers/features/github-cli:1": "latest" - } + "remoteUser": "root", + "forwardPorts": [] } \ No newline at end of file diff --git a/.devcontainer/scripts/postCreate.sh b/.devcontainer/scripts/postCreate.sh index 4b416a775..7a544c670 100755 --- a/.devcontainer/scripts/postCreate.sh +++ b/.devcontainer/scripts/postCreate.sh @@ -1,3 +1,6 @@ #!/bin/bash -sudo npm install --location=global yarn +# This script runs after the container is created +echo 'Post-create script running (/.devcontainer/scripts)...' +echo "Current folder: $(pwd)" +echo "Current user: $(whoami)" diff --git a/.github/workflows/post-create.yml b/.github/workflows/post-create.yml new file mode 100644 index 000000000..48ba3e5cb --- /dev/null +++ b/.github/workflows/post-create.yml @@ -0,0 +1,42 @@ +name: Test CI/CD with DevContainer Builder + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test-custom-builder: + runs-on: ubuntu-latest + + # Add permissions for pushing to GitHub Container Registry + permissions: + contents: read + packages: write + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + # Add authentication step for GitHub Container Registry + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Pre-build dev container image + uses: devcontainers/ci@v0.3 + with: + imageName: ghcr.io/${{ github.repository }}/devcontainer + # cacheFrom: ghcr.io/${{ github.repository }}/devcontainer + # push: always + + - name: Run make ci-build in dev container + uses: devcontainers/ci@v0.3 + with: + push: never + runCmd: python3 special_add.py + # ...existing code... \ No newline at end of file From f0c3e6ab16f6a81f281cfd09d15b161ccce5cfbb Mon Sep 17 00:00:00 2001 From: sireesha Date: Mon, 7 Jul 2025 12:39:28 +0530 Subject: [PATCH 2/4] postcreate command --- .devcontainer/scripts/post-create.sh | 7 +++++++ scripts/post-create.sh | 6 ++++++ 2 files changed, 13 insertions(+) create mode 100644 .devcontainer/scripts/post-create.sh create mode 100644 scripts/post-create.sh diff --git a/.devcontainer/scripts/post-create.sh b/.devcontainer/scripts/post-create.sh new file mode 100644 index 000000000..ed1b74943 --- /dev/null +++ b/.devcontainer/scripts/post-create.sh @@ -0,0 +1,7 @@ + +#!/bin/bash + +# This script runs after the container is created +echo 'Post-create script running (/.devcontainer/scripts)...' +echo "Current folder: $(pwd)" +echo "Current user: $(whoami)" \ No newline at end of file diff --git a/scripts/post-create.sh b/scripts/post-create.sh new file mode 100644 index 000000000..4d30a8f86 --- /dev/null +++ b/scripts/post-create.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# This script runs after the container is created +echo 'Post-create script running from (/workspace/scripts)...' +echo "Current folder: $(pwd)" +echo "Current user: $(whoami)" \ No newline at end of file From f2b52b84446767fb575dc9bd2ed72ec3572e9fd7 Mon Sep 17 00:00:00 2001 From: sireesha Date: Mon, 7 Jul 2025 12:56:56 +0530 Subject: [PATCH 3/4] added post start script --- scripts/post-start.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 scripts/post-start.sh diff --git a/scripts/post-start.sh b/scripts/post-start.sh new file mode 100644 index 000000000..4d30a8f86 --- /dev/null +++ b/scripts/post-start.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# This script runs after the container is created +echo 'Post-create script running from (/workspace/scripts)...' +echo "Current folder: $(pwd)" +echo "Current user: $(whoami)" \ No newline at end of file From a29dfc3aecbd0372bd717db16b6e7de662a8ff5c Mon Sep 17 00:00:00 2001 From: sireesha Date: Mon, 7 Jul 2025 15:51:39 +0530 Subject: [PATCH 4/4] changes to devcontainer.json --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 42eafee90..8433eb91e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -8,7 +8,7 @@ "version": "latest" } }, - "postCreateCommand": "chmod +x scripts/*.sh && scripts/post-create.sh", + "postCreateCommand": "chmod +x scripts/*.sh && ./devcontainer/scripts/post-create.sh", "postStartCommand": "chmod +x scripts/*.sh && scripts/post-start.sh", "customizations": { "vscode": {