agile-learning-institute / mentorHub

9 stars 3 forks source link

Cache docker compose info #69

Closed michquinn closed 6 months ago

michquinn commented 6 months ago

ATTN @FlatBallFlyer

Currently, mh runs three docker compose config commands upon each run, while it only needs to be executed on mh update

One possibility to save the result is to create a file like so in the update function

IMAGES=($(docker compose -f "$INSTALL_PATH/docker-compose.yaml" --profile '*' config --images))
CONTAINERS=($(docker compose -f "$INSTALL_PATH/docker-compose.yaml" --profile '*' config --services))
PROFILES=($(docker compose -f "$INSTALL_PATH/docker-compose.yaml" config --profiles))

cat <<EOF > mhvars
export IMAGES="$IMAGES"
export CONTAINERS="$CONTAINERS"
export PROFILES="$PROFILES"
EOF

Then source this file when needed

source $INSTALL_PATH/mhvars

I'm not home to test this now but once I have I can submit a PR

michquinn commented 6 months ago

Alternatively a command could be run to edit mh after the update, inserting the contents of that file in place so it doesn't have to be sourced. Looks like sed supports it

https://unix.stackexchange.com/a/32912

FlatBallFlyer commented 6 months ago

I like the first option better

FlatBallFlyer commented 6 months ago

We need to move the fetch of docker-compose up in the update logic to happen BEFORE we build those files... so that when we build them we are using the most recent compose.yaml file.