Skip to content

Instantly share code, notes, and snippets.

@chimame
Last active June 27, 2018 07:58
Show Gist options
  • Save chimame/b103f783b3e8823fe14a03242b37b9d8 to your computer and use it in GitHub Desktop.
Save chimame/b103f783b3e8823fe14a03242b37b9d8 to your computer and use it in GitHub Desktop.
Dockerコンテナ内のassets系をキャッシュするために出力する処理
#!/bin/sh
IFS=$','
CACHE_DIRS="public/assets,tmp/cache"
WORK_DIR_IN_DOCKER="/app"
i=1
docker run -it -d --entrypoint /bin/sh --name run_cache_container <image name> -c /bin/sh
for VAL in ${CACHE_DIRS}
do
docker exec run_cache_container tar czf assets_cache_${i}.tar.gz -C $WORK_DIR_IN_DOCKER $VAL
docker cp run_cache_container:${WORK_DIR_IN_DOCKER}/assets_cache_${i}.tar.gz assets_cache_${i}.tar.gz
let i++
done
docker rm run_cache_container -f
IFS=$' \t\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment