Skip to content
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

Making start-docker Contract-Agnostic #93

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

amessbee
Copy link
Contributor

@amessbee amessbee commented Aug 19, 2024

This is a twin of a PR in dapp-agoric-basics repo.

Goal of this PR is to (maybe partially) close #92. Currently running of agoriclocal chain and deploying and starting contract are intertwined in this dapp. This is somewhat unnatural as chain should not depend on the files of any specific contract - apart from the ones that designated essential for its running.
Further, running a chain independent of a specific contract will allow testing of multiple dapp simultaneously running and interacting with each other which may unlock several scenarios that a developer may want to test for.

As per discussion with @toliaqat, here is a plan:

  • docker compose file should not mount the contract directory as a volume. Rather it should mount (ideally) a single script (run-chain.sh) that necessary tasks for running of chain independently.
  • run-chain.sh should do just that - run the chain and nothing else!

yarn start:contract should handle most of the heavy work including:

  • setup a dedicated workspace for the contract (ws-offer-up here)
  • copy tools needed for building, i.e., Makefile
  • copy scripts and tools needed for required for making install-bundle, submit-proposal, vote etc. calls.
  • create contract bundles on host machine, and then copy them to the workspace in docker container.
  • copy all relevant files to workspace directory on the container.
  • make build-proposal, install-bundle, submit-proposal, vote etc. calls needed to deploy and run the contract using scripts as before.
  • update relevant docs. In particular, add guides to install agoric and agd CLI.
  • Update getting-started docs if needed.

Link to IBIS document.

@amessbee amessbee changed the title Ms/creating contract agnostic docker --WIP-- Making start-docker Contract-Agnostic --WIP-- Aug 19, 2024
@amessbee amessbee marked this pull request as ready for review August 30, 2024 14:47
@amessbee amessbee assigned frazarshad and unassigned frazarshad Aug 30, 2024
@amessbee amessbee requested review from frazarshad and Jovonni August 30, 2024 14:48
Copy link

@usmanmani1122 usmanmani1122 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:
Instead of running a container within a container (which further reduces the resources available to the child container), why don't we run two parallel docker containers and use a network bridge to communicate between them?

@@ -0,0 +1,19 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there code related to codespaces here? That should be in a different PR to make sure that we have a shorter PR to review here.

@frazarshad frazarshad removed their request for review October 15, 2024 05:41
@amessbee amessbee force-pushed the ms/creating-contract-agnostic-docker branch from ec15741 to 1b21a98 Compare October 22, 2024 12:19
@amessbee amessbee changed the title Making start-docker Contract-Agnostic --WIP-- Making start-docker Contract-Agnostic Oct 22, 2024
@amessbee
Copy link
Contributor Author

Asking users to install agoric and agd CLI to interact with getting-started seems like a big ask therefore we are moving towards the easier solution of running these commands inside the docker container ATM. T
here is little to no change needed in the docs.

@toliaqat
Copy link
Contributor

toliaqat commented Nov 6, 2024

I am removing myself from the review. I think @Jovonni or @mujahidkay are best suited to review and help make progress in this area.

@toliaqat toliaqat removed their request for review November 6, 2024 17:05
@amessbee amessbee force-pushed the ms/creating-contract-agnostic-docker branch from d984d0c to 0e73e6a Compare January 17, 2025 14:00
@amessbee
Copy link
Contributor Author

I feel this is at a reasonable shape now and we can invite reviews. Instead of the complex multi-step approach I started with above, I have now settled for a much simpler idea that disturbs least amount of artifacts to achieve the same IMO. To summarize, we

  • Anticipate a list dapps that a user may have (currently dapp-offer-up, dapp-agoric-basics, dapp-ed-cert, dapp-chain-timer, dapp-second-invite).
  • For each of the above list, if the corresponding repo exists (at a path set by an ENV variable or at ../), we mount it as a separate workspace directory in the docker container.
  • Use a named docker container agdc that can be shared among the repos, instead of a docker service.

@dckc WDYT?

@amessbee amessbee requested review from dckc and Muneeb147 January 20, 2025 13:17
@amessbee amessbee self-assigned this Jan 20, 2025
Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm particularly curious how this works with yarn create @agoric/dapp demo.

# Check if container exists but is stopped
if [ "$(docker ps -aq -f status=exited -f name=agdc)" ]; then
echo "Found stopped container 'agdc'. Removing it before starting a new one..."
docker rm agdc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing a container is irreversible, right? So if somebody happened to have a container named agdc running when trying out our stuff, this would remove it, yes? That doesn't seem fail-safe; it seems to violate the principle of least surprise.

Comment on lines +17 to +21
: ${DAPP_ED_CERT_PATH:="$(pwd)/../dapp-ed-cert"}
: ${DAPP_CHAIN_TIMER_PATH:="$(pwd)/../dapp-chain-timer"}
: ${SECOND_INVITE_PATH:="$(pwd)/../dapp-second-invite"}
: ${DAPP_OFFER_UP_PATH:="$(pwd)/../dapp-offer-up"}
: ${DAPP_AGORIC_BASICS_PATH:="$(pwd)/../dapp-agoric-basics"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should dapp-offer-up know about these other dapps?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work if somebody clones dapp-offer-up but uses something like demo as the directory name?

Does yarn create @agoric/dapp demo (from getting started) work?

# bring back chain process to foreground
wait
# Start new container with the chain startup commands
docker run -d \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docker-compose.yml syntax sure looked more straightforward.

What would you think of refactoring it to something like...

agd_image=...
linux_only=...
ports=...

...
docker run -d --name agdc $linux_only $ports $env $volumes $agd_image $start_agd

@dckc
Copy link
Member

dckc commented Jan 24, 2025

Do you plan to squash all the commits into 1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docker image should be independent of host contract
5 participants