-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: Fixes substrate-node-template docker issues #13039
fix: Fixes substrate-node-template docker issues #13039
Conversation
You committed the lock file. Please remove. |
Thanks! I've removed it now |
I tried it with the
Would it not be easier to decommission the old compose and just recommend the new one? |
thanks for your feedback. that appears to be because i increased the version in docker-compose.yml from 3.2 to 3.8 without realising its impact https://github.com/paritytech/substrate/pull/13039/files#diff-5e9a8fb875be970e9f3ad6ffe27a734686cd8540a1dbd7a0079cee876e833bbdL1, since i needed a newer version when i was using |
@ggwpez ggwpez i've got Docker CE installed on Ubuntu 20.04, by following these instructions https://www.vultr.com/docs/install-docker-ce-on-ubuntu-18-04/, which allows me to run
It includes
Then if I ran the script it detected
But to be able to run
Then if I ran the script it detected
Then I reverted to installing the older docker-compose v1.25.0 from https://github.com/docker/compose/releases/tag/1.25.0 and I got the same error as you. It was because the old Compose file format v1 didn't even support using the Then if I removed that field running it gave error i have tested it with
|
If the legacy format supports everything, why not just stick to this? Why do we need two files which are doing the same? |
great idea! some things come to mind:
i've pushed a commit that now just uses a single docker-compose.yml file, and in the script i've used a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked now with old and new version that I tried.
The bash code is a bit 🙈 but If you think its worth it.
SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") | ||
PARENT_DIR=$(dirname "$SCRIPT_DIR") | ||
mkdir -p "$PARENT_DIR/.local" | ||
mkdir -p "$PARENT_DIR/.cargo/registry" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you maybe put them into the target/
dir, so I wont forget deleting them eventually?
Also do you know if there is a way to not make docker chown these folders with root?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cheers, i'm working on fixing all that, i'll push some commits and tell you when its done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've pushed changes that address your comments.
in the changes when i added a workspace bin/node-template/Cargo.toml file instead of only building the bin/node-template/node directory that fixed the location of the /target directory, and adding to docker-compose.yml CARGO_HOME=/var/www/node-template/target/.cargo
allows .cargo files to be kept in the /target dir.
in the entrypoint.sh script i use usermod
to load the existing non-root user called nonroot
that has already been added to the prebuilt docker image 'paritytech/ci-linux:production', then i use chown -R nonroot:nonroot ...
to change ownership of the relevant folders like the chain directory and other hidden folders that get used like:
/var/www/node-template/target/debug/.cargo-lock
/var/www/node-template/target/.cargo/registry/index/github.aaakk.us.kg-x/.git/config.lock
/var/www/node-template/target/debug/build/anyhow-x/invoked.timestamp
i also create a symlink from the chain data folder to /data, so we can have a single static dev chain folder, which you can specify with --base-path=/data
, which makes it easier to access to prune since otherwise the directory might change each time and clutters up storage.
i also run arguments that the user passes into the script with su -c "$args" nonroot
, where args=$@
.
Co-authored-by: Oliver Tale-Yazdi <[email protected]>
…stall with apt-get in command
an alternative to the ugly docker-compose.yml hack where add or remove the i even got caught out recently when i switched to a different cloud server and installed docker on the new machine following this guide https://www.vultr.com/docs/install-docker-ce-on-ubuntu-18-04/, but then i got error: another unfortunate thing about using the legacy Compose file format it doesn't support top-level
also the reason why the node template dockerfile is proposed to located in the parent Substrate folder here ./docker/substrate_node_template_builder.Dockerfile with the substrate dockerfile is because inside that dockerfile itself i needed to
and that required the ./bin/node-template/docker-compose.yml file to specify the context to be but if i had instead located that dockerfile in ./bin/node-template/docker/substrate_node_template_builder.Dockerfile, then it wouldn't work if the context was i also tried combining both the node-template and substrate dockerfiles together, using an |
@ggwpez so should we get rid of support for old docker versions so we can get rid of the ugly bash code? |
Yea, just require the new version. Don't see a problem with that. |
happy to push the changes but i was busy with a hackathon. |
@ltfschoen was this correctly closed or still a wip? |
i think the PR would help the community use docker. sorry i was doing the polkadot europe hackathon so haven't had time the past couple of weeks. |
@nukemandan actually now that i think about it you were correct in closing this PR. |
docker-compose
v1 ordocker compose
v2. See difference between each here https://stackoverflow.com/questions/66514436/difference-between-docker-compose-and-docker-compose, noting that a comment at that link suggests users may be able to resolve it by installing compose standalone with docker-compose syntax https://docs.docker.com/compose/install/other/ which installs Docker Compose version v2.14.2 when you rundocker-compose version
, but i don't think that should be necessary, it needs support for latestdocker compose
v2. Previously only docker-compose was supported, so if you had installed Docker CE on a linux machine it wouldn't have that executable but it would have thedocker compose ...
executable and the script would panic. Note that I encountered the issue because I had the latestdocker compose
from installing Docker CE (i didn't have Docker Desktop because I was using a cloud provider that didn't have the required KVM support, see https://docs.docker.com/desktop/install/linux-install/)listen tcp4 0.0.0.0:9944: bind: address already in use
that port 9944 not available in this PR (for example i was running a moonbase collator on that same port, so i changed the port used by that service, but would have been easier just to modify the port mapping in docker-compose.yml to use a different local port)./bin/node-template/scripts/docker_run.sh
it would give errorerror: could not find
Cargo.tomlin
/var/www/node-templateor any parent directory
on Ubuntu 22.04, so docker-compose.yml file has been updated in this PRcargo build --release
it gave warningwarning: use of deprecated associated function
chrono::Local::today: use
Local::now()instead
, so that change has been made in this PRcargo build --release
where warning iswarning: Git command failed with status: exit status: 128; warning: Could not find
.git/HEADsearching from '/var/www/node-template/node' upwards!
printf
instead ofecho
so newline characters work (alternative isecho -e
)type: bind
for each instead.mkdir -p "$PARENT_DIR/.local"
in the docker_run.sh file. If neither approaches are followed then it gives errorError response from daemon: invalid mount config for type "bind": bind source path does not exist: ~/substrate/bin/node-template/.local
docker compose run --rm --service-ports dev $@
by removing the--rm
so it doesn't delete the container, that way if the user stops the container that automatically starts running they don't lose the container and have to create it again, instead they could just run the following to find and enter the container using the last container that was created, and then inside the container optionally run commandscargo build ...
andtarget/debug ...
for development instead ofcargo build --release ...
andtarget/release ...
that are for productionFixes #228
orRelated #1337
.