I'm trying to use AWS Codebuild - Local Custom Cache. I'm failing to perform the simplest task of caching a file between builds. What's explained here: AWS CodeBuild local cache failing to actually cache? doesn't work for me.
This is my buildspec.yml
version: 0.2
phases:
pre_build:
commands:
- CACHE_DIR='docker-img-cache'
- CACHED_FILE='docker-img-cache/test.md'
build:
commands:
- ls $CACHE_DIR
- ls -sh $CACHED_FILE || true
# If file exist, print its content and size
- if [ -f $CACHED_FILE ]; then echo "File is in cache"; ls -sh $CACHED_FILE; fi
# Else create file, print its size
- if ! [ -f $CACHED_FILE ]; then echo "Hello cache world" > $CACHED_FILE; echo "File created"; ls -sh $CACHED_FILE; fi
- ls $CACHE_DIR
cache:
paths:
- 'docker-img-cache'
Only the directory gets cached, but without the file inside. I've already tried with the '/*
'/**/*'
suffixes.
If you try it on your own, you will be able to see that file gets created on every build. However the directory exists.