-
Notifications
You must be signed in to change notification settings - Fork 82
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
Multi stage Docker build cache documentation improvement #509
Comments
The customer attached an updated file: # For more Ruby information and examples, see
# https://docs.semaphoreci.com/article/73-ruby
version: v1.0
name: Example Ruby API
agent:
machine:
type: e1-standard-2
os_image: ubuntu1804
blocks:
- name: Build
task:
secrets:
- name: quay-pull-secrets
prologue:
commands:
- checkout
jobs:
- name: Build Docker image
# With workaround for multi-stage cache: https://github.com/moby/moby/issues/34715
commands:
- echo ${DOCKER_PASSWORD} | docker login ${DOCKER_URL} --username ${DOCKER_USERNAME} --password-stdin
- image=quay.io/mycompany/example-ruby-api
- image_tag=${SEMAPHORE_GIT_BRANCH/refs\/tags\//}
- image_tag=${image_tag/\//-}
- commit_hash=$(git log -n 1 --pretty=format:'%H')
- docker pull $(grep -oE 'FROM .+$' Dockerfile | head -n 1 | cut -d ' ' -f 2) || true
- docker pull ${image}:${image_tag}_builder || true
- docker pull ${image}:${image_tag} || true
- docker build --cache-from ${image}:${image_tag}_builder -t ${image}:${image_tag}_builder --target builder .
- docker build --cache-from ${image}:${image_tag},${image}:${image_tag}_builder -t ${image}:${image_tag} .
- if [[ "$SEMAPHORE_GIT_BRANCH" != *"refs/tags/"* ]]; then docker push ${image}:${image_tag}_builder; fi
- docker push ${image}:${image_tag}
- if [[ "$SEMAPHORE_GIT_BRANCH" != *"refs/tags/"* ]]; then docker tag ${image}:${image_tag} ${image}:${commit_hash} && docker push ${image}:${commit_hash}; fi
- if [ "$(git rev-parse --abbrev-ref HEAD)" == "develop" ]; then docker tag ${image}:${image_tag} ${image}:latest && docker push ${image}:latest; fi |
Hello, I'm very interested in this too. I tried many things, but could not make it work. Thanks for working on this 🙏 |
@CommanderK5 Can you take a look at this? Whenever you have the time 😄 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feedback from a customer:
He attached the following file:
The text was updated successfully, but these errors were encountered: