From 8e0ab6615e362ef3c706d7da20c02c239c0a95c3 Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Mon, 22 Jul 2024 13:21:52 +0500 Subject: [PATCH 01/16] feat: using image basked with GH+DinD --- .devcontainer/devcontainer.json | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 18e4d42e..eafd6c9b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,9 +1,9 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node { - "name": "Node.js", + "name": "Node+GH+DinD", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18-bookworm", + "image": "mudassirshabbir/dab:basic", // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts": [5173, 1317, 26657, 26656], @@ -26,10 +26,5 @@ } }, // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "bash /workspaces/dapp-agoric-basics/make_ports_public.sh 26657 5173 1317", - "postStartCommand": "yarn install", - "features": { - "ghcr.io/devcontainers/features/docker-in-docker:2": {}, - "ghcr.io/devcontainers/features/github-cli:1": {} - } + "postCreateCommand": "bash /workspaces/dapp-agoric-basics/make_ports_public.sh 26657 5173 1317" } From b5dd3e94f4d968e4ce94aea785a6623b284e6e60 Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Mon, 22 Jul 2024 13:28:19 +0500 Subject: [PATCH 02/16] feat: yarn installed baked in now --- .devcontainer/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index eafd6c9b..20590273 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,7 +3,8 @@ { "name": "Node+GH+DinD", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mudassirshabbir/dab:basic", + // "image": "mudassirshabbir/dab:basic", + "image": "mudassirshabbir/dab:updated", // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts": [5173, 1317, 26657, 26656], From de8511ab75b58c9d1cc6e039095715e14dbbf56d Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Mon, 22 Jul 2024 16:22:08 +0500 Subject: [PATCH 03/16] fix: docker-in-docker is needed --- .devcontainer/devcontainer.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 20590273..11b4edcc 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -27,5 +27,9 @@ } }, // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "bash /workspaces/dapp-agoric-basics/make_ports_public.sh 26657 5173 1317" + "postCreateCommand": "bash /workspaces/dapp-agoric-basics/make_ports_public.sh 26657 5173 1317", + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers/features/github-cli:1": {} + } } From 34b9cf13c6e13b55c606bda64e3204cd4a1e9ee8 Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Mon, 22 Jul 2024 16:38:14 +0500 Subject: [PATCH 04/16] feat: further automation --- .devcontainer/devcontainer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 11b4edcc..f18c4975 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -31,5 +31,7 @@ "features": { "ghcr.io/devcontainers/features/docker-in-docker:2": {}, "ghcr.io/devcontainers/features/github-cli:1": {} - } + }, + // TODO: The image address in the line below needs to be updated + "postStartCommand": "yarn install && docker run -d -v '.:/workspace' --platform linux/amd64 -p 26656:26656 -p 26657:26657 -p 1317:1317 mudassirshabbir/agoric:mc2 && yarn start:ui" } From ade5a053422e12254b25083ef2131b4614fd96f6 Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Tue, 23 Jul 2024 08:22:35 +0500 Subject: [PATCH 05/16] fix: baking yarn install --- .devcontainer/Dockerfile | 14 ++++++++++++++ .devcontainer/devcontainer.json | 33 +++++++++++++++++++++------------ 2 files changed, 35 insertions(+), 12 deletions(-) create mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..1a33effb --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,14 @@ +# Use the base image from the provided Docker command +FROM mudassirshabbir/dab:mc3 + +# Set the working directory +WORKDIR /workspace + +# Expose the ports as specified in the docker run command +EXPOSE 26656 +EXPOSE 26657 +EXPOSE 1317 + + +# Set the entrypoint or command if necessary (adjust as needed) +ENTRYPOINT ["/bin/bash /workspaces/dapp-agoric-basics/make_ports_public.sh 26657 5173 1317"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f18c4975..6c4bb887 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,11 +1,20 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node { - "name": "Node+GH+DinD", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - // "image": "mudassirshabbir/dab:basic", - "image": "mudassirshabbir/dab:updated", - + "name": "Node+GH+DinD", + "build": { + "dockerfile": "Dockerfile", + "context": ".." + }, + "runArgs": [ + "--privileged", + "--platform", "linux/amd64" + ], + "workspaceFolder": "/workspace", + "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached", + "mounts": [ + "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" + ], // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts": [5173, 1317, 26657, 26656], "portsAttributes": { @@ -27,11 +36,11 @@ } }, // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "bash /workspaces/dapp-agoric-basics/make_ports_public.sh 26657 5173 1317", - "features": { - "ghcr.io/devcontainers/features/docker-in-docker:2": {}, - "ghcr.io/devcontainers/features/github-cli:1": {} - }, - // TODO: The image address in the line below needs to be updated - "postStartCommand": "yarn install && docker run -d -v '.:/workspace' --platform linux/amd64 -p 26656:26656 -p 26657:26657 -p 1317:1317 mudassirshabbir/agoric:mc2 && yarn start:ui" + // "postCreateCommand": "bash /workspaces/dapp-agoric-basics/make_ports_public.sh 26657 5173 1317", + // "features": { + // "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + // "ghcr.io/devcontainers/features/github-cli:1": {} + // }, + // // TODO: The image address in the line below needs to be updated + // "postStartCommand": "yarn install && docker run -d -v '.:/workspace' --platform linux/amd64 -p 26656:26656 -p 26657:26657 -p 1317:1317 mudassirshabbir/agoric:mc2 && yarn start:ui" } From 7e4a74968d90b173532ba48dd3b734d015b74a20 Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Tue, 23 Jul 2024 09:04:54 +0500 Subject: [PATCH 06/16] fix: baked yarn install --- .devcontainer/Dockerfile | 2 +- entrypoint.sh | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100755 entrypoint.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 1a33effb..46e20804 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -11,4 +11,4 @@ EXPOSE 1317 # Set the entrypoint or command if necessary (adjust as needed) -ENTRYPOINT ["/bin/bash /workspaces/dapp-agoric-basics/make_ports_public.sh 26657 5173 1317"] +ENTRYPOINT ["/workspaces/dapp-agoric-basics/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 00000000..491c3285 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -x + +cp -r /usr/src/cache/node_modules /workspaces/dapp-agoric-basics/ + +/workspaces/dapp-agoric-basics/make_ports_public.sh 5173 1317 26657 26656 \ No newline at end of file From 954cfb91cc94dcd6691b36ede22cbe7f7491b9bf Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Tue, 23 Jul 2024 09:23:14 +0500 Subject: [PATCH 07/16] fix: docker entrypoint --- .devcontainer/Dockerfile | 5 ++++- entrypoint.sh | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 46e20804..399e178e 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -8,7 +8,10 @@ WORKDIR /workspace EXPOSE 26656 EXPOSE 26657 EXPOSE 1317 +EXPOSE 5173 - +RUN "/workspaces/dapp-agoric-basics/entrypoint.sh" # Set the entrypoint or command if necessary (adjust as needed) ENTRYPOINT ["/workspaces/dapp-agoric-basics/entrypoint.sh"] + +CMD ["/bin/bash"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 491c3285..5eaf1ee8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,5 @@ #!/bin/bash set -x - cp -r /usr/src/cache/node_modules /workspaces/dapp-agoric-basics/ - -/workspaces/dapp-agoric-basics/make_ports_public.sh 5173 1317 26657 26656 \ No newline at end of file +/workspaces/dapp-agoric-basics/make_ports_public.sh 5173 1317 26657 26656 +exec /bin/bash \ No newline at end of file From 119d7ca52f15499e32fd06a4a8f2d1a3d18cb9b0 Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Tue, 23 Jul 2024 09:28:07 +0500 Subject: [PATCH 08/16] fix: entry point --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 5eaf1ee8..14f3173b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,4 +2,4 @@ set -x cp -r /usr/src/cache/node_modules /workspaces/dapp-agoric-basics/ /workspaces/dapp-agoric-basics/make_ports_public.sh 5173 1317 26657 26656 -exec /bin/bash \ No newline at end of file +# exec /bin/bash \ No newline at end of file From 98984b4427aefbada697f48202300b1dc83c8b1b Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Tue, 23 Jul 2024 09:35:50 +0500 Subject: [PATCH 09/16] fix: entry point --- .devcontainer/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 399e178e..914dc8d4 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -10,8 +10,8 @@ EXPOSE 26657 EXPOSE 1317 EXPOSE 5173 -RUN "/workspaces/dapp-agoric-basics/entrypoint.sh" +RUN entrypoint.sh # Set the entrypoint or command if necessary (adjust as needed) -ENTRYPOINT ["/workspaces/dapp-agoric-basics/entrypoint.sh"] +ENTRYPOINT ["/workspace/entrypoint.sh"] CMD ["/bin/bash"] \ No newline at end of file From c50214f04e6a241ccb60c9ffcf3a44089aadfd00 Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Tue, 23 Jul 2024 09:50:38 +0500 Subject: [PATCH 10/16] fix: entry point --- .devcontainer/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 914dc8d4..380ba19f 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -10,8 +10,7 @@ EXPOSE 26657 EXPOSE 1317 EXPOSE 5173 -RUN entrypoint.sh # Set the entrypoint or command if necessary (adjust as needed) -ENTRYPOINT ["/workspace/entrypoint.sh"] +ENTRYPOINT ["/usr/scripts/entrypoint.sh"] CMD ["/bin/bash"] \ No newline at end of file From 24dfbd282b44b37870f13d6ed164815c07d0d430 Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Tue, 23 Jul 2024 09:57:56 +0500 Subject: [PATCH 11/16] fix: entry point inf --- .devcontainer/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 380ba19f..e4833eb7 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -10,6 +10,7 @@ EXPOSE 26657 EXPOSE 1317 EXPOSE 5173 +RUN /usr/scripts/entrypoint.sh # Set the entrypoint or command if necessary (adjust as needed) ENTRYPOINT ["/usr/scripts/entrypoint.sh"] From 07be49c930ad5d8583e85e20a23fdf68bb7f4736 Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Tue, 23 Jul 2024 10:19:50 +0500 Subject: [PATCH 12/16] fix: entry point inf+1 --- .devcontainer/Dockerfile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index e4833eb7..c4ed23a2 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,17 +1,11 @@ # Use the base image from the provided Docker command FROM mudassirshabbir/dab:mc3 -# Set the working directory -WORKDIR /workspace - # Expose the ports as specified in the docker run command EXPOSE 26656 EXPOSE 26657 EXPOSE 1317 EXPOSE 5173 -RUN /usr/scripts/entrypoint.sh # Set the entrypoint or command if necessary (adjust as needed) -ENTRYPOINT ["/usr/scripts/entrypoint.sh"] - -CMD ["/bin/bash"] \ No newline at end of file +ENTRYPOINT ["/bin/bash"] From 470ceb395d60074a6df2ddb9c48623b777450a15 Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Tue, 23 Jul 2024 10:57:06 +0500 Subject: [PATCH 13/16] fix: entry point inf+2 --- .devcontainer/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index c4ed23a2..4edfa1d4 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -7,5 +7,8 @@ EXPOSE 26657 EXPOSE 1317 EXPOSE 5173 +RUN "export NODE_PATH=/usr/src/cache/" # Set the entrypoint or command if necessary (adjust as needed) ENTRYPOINT ["/bin/bash"] + +CMD "/bin/bash" From b247221b01230ca10d02625df15ec4475212516e Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Tue, 23 Jul 2024 11:02:59 +0500 Subject: [PATCH 14/16] fix: entry point inf+3 --- .devcontainer/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 4edfa1d4..f3e60dc3 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -7,7 +7,8 @@ EXPOSE 26657 EXPOSE 1317 EXPOSE 5173 -RUN "export NODE_PATH=/usr/src/cache/" +# Set the NODE_PATH environment variable +ENV NODE_PATH=/usr/src/cache # Set the entrypoint or command if necessary (adjust as needed) ENTRYPOINT ["/bin/bash"] From b48c4667c09bb5e97be815744b97e6148e152782 Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Tue, 23 Jul 2024 20:56:57 +0500 Subject: [PATCH 15/16] fix: entry point inf+5 --- .devcontainer/devcontainer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6c4bb887..72507dbb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -36,6 +36,7 @@ } }, // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "/bin/bash /workspaces/dapp-agoric-basics/entrypoint.sh" // "postCreateCommand": "bash /workspaces/dapp-agoric-basics/make_ports_public.sh 26657 5173 1317", // "features": { // "ghcr.io/devcontainers/features/docker-in-docker:2": {}, From 0f38716c8ebf09427a909c6eb625a5582df8ba1a Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Wed, 24 Jul 2024 17:19:23 +0500 Subject: [PATCH 16/16] chore: adding GHCS README for followup work on this WIP --- .devcontainer/Dockerfile | 4 +-- README-GHCS.md | 74 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 README-GHCS.md diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index f3e60dc3..6ee8d70f 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -10,6 +10,6 @@ EXPOSE 5173 # Set the NODE_PATH environment variable ENV NODE_PATH=/usr/src/cache # Set the entrypoint or command if necessary (adjust as needed) -ENTRYPOINT ["/bin/bash"] +ENTRYPOINT ["/bin/bash -c"] -CMD "/bin/bash" +CMD "/bin/bash -c" diff --git a/README-GHCS.md b/README-GHCS.md new file mode 100644 index 00000000..39a1b741 --- /dev/null +++ b/README-GHCS.md @@ -0,0 +1,74 @@ +# Running `dapp-agoric-basics` on GHCS + +This README outlines the instructions, directions, and steps currently being followed in this PR to make the experience of using GHCS more efficient. For the most part the instructions in the original README should work in this PR as well. However, the ultimate goal is to have a dApp running in a chain with a UI without having to follow any of those steps. This is currently achievable but it takes time and we want to reduce this wait time as much as possible. + +## Important Steps + +- A Dockerfile is introduced in `.devcontainer` directory that loads an image `mudassirshabbir/dab:mc3`. This image contains a linux system with node version `18.20`, GitHub CLI, Docker CLI, and current `dapp-agoric-basics` repo with `yarn install` already baked. +- `dapp-agoric-basics` repo with `yarn install` is baked in `/usr/src/cache`. +- The Dockerfile is already configured in `devcontainer.json` file that is read by GHCS. +- Currently docker is loaded in `--privileged` mode mainly because we want to run docker-in-docker for chain using following `mount`: +```Dockerfile +"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" +``` +- There is an `entrypoint.sh` script that is used to copy the installed `node_modules` to the current workspaces that is mounted on `/workspace`. +- Instead of running `yarn start:docker` followed by `yarn start:contract`, we have created a docker image of the chain (`a3p`) with contract already deployed on it. +```sh +docker run -d -v ".:/workspace" mudassirshabbir/a3p:dab +``` +This saves us about five minutes on average. Once done, we can simply run `yarn start:ui` and we are good to go. + +## What Does Not Work at This Point + +Currently, we need to perform `yarn install` manually. The work to bake it in first docker iamge is unfinished. The `/usr/src/cache` version of the repo has all the modules but copying it to `/workspace` does not provide intended results. + +Below are some of the instructions that be needed to resume the task from here. + +## Docker `dab:mc3` Image Construction + +Docker image construction is done through `docker commit` command. The following instructions are needed to be run to create the first docker image: + +```sh +docker run --privileged -it -v ".:/workspace" -v /var/run/docker.sock:/var/run/docker.sock --platform linux/amd64 -p 26656:26656 -p 26657:26657 -p 1317:1317 node:18.20 /bin/bash + +# Update package list and install dependencies +apt-get update +apt-get install -y curl + +# Download and install GitHub CLI +curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg +chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg +echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null +apt-get update +apt-get install -y gh + +# Install Docker +apt-get update +apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release + +# Add Docker’s official GPG key +curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg + +# Set up the stable repository +echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null + +# Install Docker Engine +apt-get update +apt-get install -y docker-ce docker-ce-cli containerd.io + +# Enable Docker daemon +dockerd & +``` + +```sh +mkdir /usr/src/cache +cd /usr/src/cache +cp -r /workspace/* ./ +yarn install +``` + +After this point, I use `docker commit` to create an image. + +## Docker `a3p:dab` Image Construction + +This is done through straightforward `yarn start:docker`, `yarn start:contract`, followed by a `docker commit`. This can be automated through `compose` and/or `buid` but currently there is no need. \ No newline at end of file