How to prevent Dockerfile caching git clone

后端 未结 7 589
忘了有多久
忘了有多久 2020-11-30 08:19

I have a Dockerfile trying to package and deploy a web app to a container. The code of app fetches from git repository during Docker image building. Here\'s the Dockerfile s

7条回答
  •  半阙折子戏
    2020-11-30 09:08

    for anyone who has this problem with Gitlab repositories:

    Gitlab has this annoying branch id method when calling their API, the ID will appear under your repository name

    # this will copy the last change from your brach and it'll invalidate the cache if there was a new change
    ADD "https://gitlab.com/api/v4/projects/${PROJECT_ID}/repository/branches/master?private_token=${GIT_TOKEN}" /tmp/devalidateCache
    
    # the actual clone
    RUN git clone --depth=1 https://${GIT_USER}:${GIT_TOKEN}@gitlab.com/${git_file_uri} ${BASE_BUILD_PATH}
    

提交回复
热议问题