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

docker: fix slow docker container start up #5513

Merged
merged 1 commit into from
Jun 28, 2023

Conversation

shiqizng
Copy link
Contributor

Algod container v3.16.2-stable is taking 30s longer to start up than v3.15.1. This issue occurs when running the container as a root user. This PR sets the container to use a non-root user as in v3.15.1.

A test has been ran from a forked branch with this change.
docker build -t algod-local --no-cache --build-arg BRANCH=v3.16.2 --build-arg URL=https://github.com/shiqizng/go-algorand.git .

and the warm up time is down to 7s after the change.

Starting algod-local:latest
Waiting for /v2/status ......
Took 7s
#!/bin/bash
export TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

wait_for_status() {
   echo -n "Waiting for /v2/status "
   for i in {1..60}; do
      curl --fail http://localhost:8080/v2/status --header "X-Algo-API-Token: $TOKEN" &>/dev/null
      if [ $? -eq 0 ]; then
         echo 
         echo "Took ${i}s"
         return
      fi
      echo -n .
      sleep 1
   done
}

get_warmup_local() {
   version=$1
   echo "Starting algod-local:$version"
   docker run \
      --name algod_warm_local \
      -d \
      --env START_KMD=1 \
      --env TOKEN=$TOKEN \
      -p 8080:8080 \
      algod-local:$version >/dev/null
   
   wait_for_status
#    echo "Cleaning up ..."   
      docker stop algod_warm_local >/dev/null
      docker rm algod_warm >/dev/null
   echo
}
get_warmup_local latest

@shiqizng shiqizng self-assigned this Jun 28, 2023
@shiqizng shiqizng requested review from winder and a team June 28, 2023 21:23
@shiqizng shiqizng changed the title enhancement: fix slow start up enhancement: fix slow docker container start up Jun 28, 2023
@codecov
Copy link

codecov bot commented Jun 28, 2023

Codecov Report

Merging #5513 (320ec34) into master (533507a) will increase coverage by 0.03%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #5513      +/-   ##
==========================================
+ Coverage   55.78%   55.82%   +0.03%     
==========================================
  Files         446      446              
  Lines       63228    63228              
==========================================
+ Hits        35274    35298      +24     
+ Misses      25583    25567      -16     
+ Partials     2371     2363       -8     

see 6 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@winder winder merged commit 68ebeb5 into algorand:master Jun 28, 2023
@winder winder changed the title enhancement: fix slow docker container start up docker: fix slow docker container start up Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants