{"id":24054620,"url":"https://github.com/cardinal-cryptography/docker-ink-dev","last_synced_at":"2025-02-26T10:44:22.503Z","repository":{"id":65512439,"uuid":"582739046","full_name":"Cardinal-Cryptography/docker-ink-dev","owner":"Cardinal-Cryptography","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-27T13:05:43.000Z","size":50,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-09T03:49:00.145Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cardinal-Cryptography.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-12-27T18:24:22.000Z","updated_at":"2024-09-03T21:47:41.000Z","dependencies_parsed_at":"2024-01-30T10:28:40.405Z","dependency_job_id":"1c381436-ba10-48f9-becb-7d38e33623b3","html_url":"https://github.com/Cardinal-Cryptography/docker-ink-dev","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cardinal-Cryptography%2Fdocker-ink-dev","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cardinal-Cryptography%2Fdocker-ink-dev/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cardinal-Cryptography%2Fdocker-ink-dev/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cardinal-Cryptography%2Fdocker-ink-dev/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cardinal-Cryptography","download_url":"https://codeload.github.com/Cardinal-Cryptography/docker-ink-dev/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240840048,"owners_count":19866164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-09T03:49:02.777Z","updated_at":"2025-02-26T10:44:22.474Z","avatar_url":"https://github.com/Cardinal-Cryptography.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ink-dev\n\nBuild ink contracts without worrying up about setting up your environment with correct dependencies.\n\nThis repository contains minimal (at least per its authors knowledge) docker container capable of compiling and building ink! 4.0 contracts.\n\n## Usage\n*This works for cases where contract doesn't depend on other contracts by path. For that, see advanced usage*\n\nSuggested developer usage is to add the following function to your ~/.bashrc:\n\n```sh\nfunction ink-build() {\n  docker run \\\n    -v ${PWD}:/code \\\n    --platform linux/amd64 \\\n    --rm -it public.ecr.aws/p6e8q1z1/ink-dev:latest \\\n    cargo contract build --release --quiet\n}\n```\n**NOTE:** For ARM use `--platform linux/arm64/v8` instead.\n\nDon't forget to `source ~/.bashrc` before first usage.\n\nThen use in your project:\n```sh\n$ cd my-project\n$ ink-build()\n```\n\nOr, more flexible:\n```sh\nfunction ink-dev() {\n  docker run --rm -it \\\n    -v ${PWD}:/code \\\n    -v ~/.cargo/git:/usr/local/cargo/git \\\n    -v ~/.cargo/registry:/usr/local/cargo/registry \\\n    --platform linux/amd64 \\\n    -u $UID:$(id -g) \\\n    public.ecr.aws/p6e8q1z1/ink-dev:latest \"$@\"\n}\n```\n\nwhich will now allow for passing in different commands and/or arguments:\n```sh\n$ ink-dev cargo contract check\n$ ink-dev cargo contract build --manifest-path some/other/project/Cargo.toml\n```\n\n### Generate `ink!` types with `ink-wrapper`\nAnother potential use case is to access [ink-wrapper](https://github.com/Cardinal-Cryptography/ink-wrapper/) within the environment and generate `ink!` types based on the contract metadata file. This can be done as follows:\n\n```sh\nfunction ink-wrapper {\n  docker run --rm \\\n    -u $UID:$(id -g) \\\n    -v \"${PWD}\":/code \\\n    -v ~/.cargo/git:/usr/local/cargo/git \\\n    -v ~/.cargo/registry:/usr/local/cargo/registry \\\n    --entrypoint /bin/sh \\\n    public.ecr.aws/p6e8q1z1/ink-dev:latest \\\n    -c \"ink-wrapper -m metadata.json | rustfmt --edition 2021 \u003e src/ink_contract.rs\"\n}\n```\n\nThis will use `metadata.json` to generate `ink_contract.rs` which will contain useful types such a representation of the contract and the methods defined on it.\n\n\n## Advanced usage\n\nRemember, since mounting volume for the Docker container will mount only that directory recursively any files in the parent directories will not be available/visible inside the container. Below, we present solutions to some more common scenarios in which you might want to use the container.\n\n### Overriding Rust\n\nIf your project have similar structure to the following:\n```sh\nmy-app/\n├─ ink-project-a/\n│  ├─ Cargo.toml\n│  ├─ lib.rs\n├─ ink-project-b/\n│  ├─ Cargo.toml\n│  ├─ lib.rs\n├─ rust-toolchain\n```\nwhere you want to overwrite Rust for all projects inside `my-app`, you will have to mount `my-app` as docker volume. Only then the `rust-toolchain` overrides will be \"visible\" for both Ink projects.\n\nExample command (assuming `PWD=/my-app`):\n```sh\ndocker run --rm -v ${PWD}:/code public.ecr.aws/p6e8q1z1/ink-dev:latest cargo contract build --release --manifest-path ink-project-a/Cargo.toml\n```\n\nBy providing `--manifest-path` we can specify exactly which project we want to build.\n\n\n### Path dependencies in `Cargo.toml`\n\nIf your contract depends on other contracts using its path, example:\n```toml\n# imaginary Cargo.toml of your contract\n[dependencies]\nmy_other_contract = { path = \"../other-contract\" features = [\"ink-as-dependency\"] }\n```\nThen using it as described in previous section will fails with `[ERROR]: cargo metadata`, that's b/c the `my_other_contract` dependency isn't loaded into docker container.\n\nFor these cases, we need to mount additional directories manually:\n```sh\n  docker run --rm -it \\\n    -v ${PWD}:/code \\\n    -v ~/.cargo/git:/usr/local/cargo/git \\\n    -v ~/.cargo/registry:/usr/local/cargo/registry \\\n    -v ${PWD}/../other-contract:/other-contract\n    --platform linux/amd64 \\\n    -u $UID:$(id -g) \\\n    public.ecr.aws/p6e8q1z1/ink-dev:latest \\\n    cargo contract build --release --quiet\n```\nNotice the additional `-v ${PWD}/../other-contract:/other-contract` which will mount your dependency so that it's visible in the docker container.\n\n## Building image\n\n\u003e The image is built on minimal Debian linux distribution to  ensure minimal resulting image size. Only minimal Rust dependencies are installed.\n\nIn the root directory run `make build-image`. \n\n`optimized-build.toml` file contains special build profile used for building `cargo-contract` package which results in smaller binary than when using defaults.\n\n\n## Testing\n\nTo test that the resulting image can build contracts written in ink, run `make test-contract-x86_64` (if you're running on ARM, execute `test-contract-arm64`) and verify that `test-contract/target` contains correct results.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcardinal-cryptography%2Fdocker-ink-dev","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcardinal-cryptography%2Fdocker-ink-dev","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcardinal-cryptography%2Fdocker-ink-dev/lists"}