0

So I have a docker file which compiles and installs gtsam with cython wrapper. The docker setup works fine on the local machine but it runs out of memory when building on docker hubs automated build. I believe I can reduce the memory usage by changing to make -j1, but I'd still like faster builds when performed locally. I tried accessing the sys/fs/cgroup/memory/memory.limit_in_bytes which shows to be 9223372036854771712 way more then the 2G limit on the servers.

Is there a way to detect if the build is taking place through the automated build and accordingly adjust the -j flag

Vik
  • 690
  • 7
  • 22
  • 1
    Set an environment variable when running in automated build system and pass it docker build via --build-arg or pass it to docker run via --env – user1452962 Jun 22 '20 at 19:36

1 Answers1

1

Docker Hub sets environment variables that are available at build time.

For example, you can test if the build process happens on Docker Hub by checking if SOURCE_BRANCH is set.

The full list of env variables can be found here.

Arik
  • 5,266
  • 1
  • 27
  • 26
  • This would be a great solution. I can't make it work though. Do I need to add an ENV SOURCE_BRANCH=$SOURCE_BRANCH line to the docker file or will this variable be automatically available? – Vik Jun 22 '20 at 21:41
  • I got my answer on how to do this from https://stackoverflow.com/questions/45277186/is-it-possible-to-add-environment-variables-in-automated-builds-in-docker-hub – Vik Jun 23 '20 at 00:37