Skip to content

Conversation

@qwersem
Copy link
Contributor

@qwersem qwersem commented Oct 30, 2025

Instead of running multiple containers, it is enough to use just one.

Instead of running multiple containers, it is enough to use just one.

Signed-off-by: Evgeny Semenov <[email protected]>
@qwersem qwersem force-pushed the fix-reduce-containers-number branch from db529af to 77c8385 Compare October 30, 2025 22:31
@qwersem qwersem changed the title fix: run / container once fix: run docker/podman container once Oct 30, 2025
Copy link
Collaborator

@dhower-qc dhower-qc left a comment

Choose a reason for hiding this comment

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

I think several of these commands are already elided because they are gated by a file existence check (for example, bundle install only runs if $ROOT/.home/.gems is missing).

Is that also your understanding, or is there something I'm missing here?

Also,

OLDDIR=$PWD
cd $ROOT
${RUN} bundle install
run bundle install
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this (and other) setup commands already run just once since they are conditioned on the existence of file ($ROOT/.home/.gems) in this case. Are you seeing them run multiple times anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change doesn't refuse existence checks. If we shouldn't do something based on checks then this command won't be accumulated to CONTAINER_SETUP_CMD and won't be executed. It does full build inside only one container instead of multiple needless creation and removing of containers.

fi

source ${ROOT}/.home/.venv/bin/activate
run source ${ROOT}/.home/.venv/bin/activate
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this (I think) sets environment variables in the host, it might need to run every time anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess if we build docs inside container so we need to activate Python venv there. Activation on the host doesn't share environment variables implicitly into container.

riscv-unified-db$ export ROOT=$PWD
riscv-unified-db$ source ${ROOT}/.home/.venv/bin/activate
(.venv) riscv-unified-db$ env | grep VIRTUAL_ENV
VIRTUAL_ENV=/home/q/workspace/sync_upstream/riscv-unified-db/.home/.venv
VIRTUAL_ENV_PROMPT=(.venv)
(.venv) riscv-unified-db$ docker run --rm -v ${ROOT}:${ROOT} -w ${ROOT} riscvintl/udb:0.9 bash -c "env"
HOSTNAME=2fe0d945961c
PWD=/home/q/workspace/sync_upstream/riscv-unified-db
container=podman
HOME=/root
TERM=xterm
SHLVL=0
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
DEBIAN_FRONTEND=noninteractive
_=/usr/bin/env
# WRONG: We don't have venv variables inside container.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. I use singularity, where environment variables from the host appear in the container by default (and do not persist in the container). In Docker, will the environment variable persist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is --env option which allows to set variable inside. But it's also possible to define through shell call to use it one time.

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.

2 participants