Open csidyel opened 5 years ago
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.
I have 7 layers (4 for the release
, 2 for local developers tools and 1 for testing purposes, local and CI/CD) so maybe that's why it's a bit more complicated to make it work.
Thanks for working on this 🙏
@CommanderK5 Can you take a look at this? Whenever you have the time 😄
Feedback from a customer:
He attached the following file: