Commit 85f5501c authored by Clement Bois's avatar Clement Bois
Browse files

fix: support dotenv for non-root images

parent 073d79a5
Loading
Loading
Loading
Loading
+19 −23
Original line number Diff line number Diff line
@@ -77,6 +77,22 @@ variables:
    log_info "Registry authentication configured for \\e[33;1m${maven_jib_snapshot_registry_host}\\e[0m"
  }

  function create_dotenv_file() {
    jib_digest=$1
    jib_image=${2:-$MAVEN_JIB_SNAPSHOT_IMAGE}

    jib_repository=${jib_image%:*}
    jib_tag=${jib_image##*:}
    {
      echo "jib_image=$jib_image"
      echo "jib_image_digest=$jib_repository@$jib_digest"
      echo "jib_repository=$jib_repository"
      echo "jib_tag=$jib_tag"
      echo "jib_digest=$jib_digest"
    } > jib.env
    chmod 644 jib.env
  }
  
  configure_registries_auth

  # ENDSCRIPT
@@ -92,18 +108,7 @@ mvn-build:
      com.google.cloud.tools:jib-maven-plugin:build 
      $MAVEN_JIB_BUILD_ARGS
    - output_coverage
    # create dotenv file
    - jib_digest=$(cat target/jib-image.digest | cut -f2 -d':' )
    - jib_repository=${MAVEN_JIB_SNAPSHOT_IMAGE%:*}
    - jib_tag=${MAVEN_JIB_SNAPSHOT_IMAGE##*:}
    - |
      {
        echo "jib_image=$MAVEN_JIB_SNAPSHOT_IMAGE"
        echo "jib_image_digest=$jib_repository@$jib_digest"
        echo "jib_repository=$jib_repository"
        echo "jib_tag=$jib_tag"
        echo "jib_digest=$jib_digest"  
      } > jib.env
    - create_dotenv_file "$(cat target/jib-image.digest | cut -f2 -d':' )"
  artifacts:
    reports:
      dotenv:
@@ -215,16 +220,7 @@ mvn-deploy-release:
      skopeo copy --src-authfile $BUILDTOOL_HOME/.docker/config.json --dest-authfile $BUILDTOOL_HOME/.docker/release-config.json ${MAVEN_JIB_PUBLISH_ARGS} docker://$MAVEN_JIB_SNAPSHOT_IMAGE docker://$MAVEN_JIB_RELEASE_IMAGE
      log_info "Well done, your image is published and can be downloaded by doing: docker pull $MAVEN_JIB_RELEASE_IMAGE"
    - jib_digest=$(skopeo inspect --authfile $BUILDTOOL_HOME/.docker/release-config.json --format='{{ .Digest }}' "docker://$MAVEN_JIB_RELEASE_IMAGE")
    - jib_repository=${MAVEN_JIB_RELEASE_IMAGE%:*}
    - jib_tag=${MAVEN_JIB_RELEASE_IMAGE##*:}
    - |
      {
        echo "jib_image=$MAVEN_JIB_RELEASE_IMAGE"
        echo "jib_image_digest=$jib_repository@$jib_digest"
        echo "jib_repository=$jib_repository"
        echo "jib_tag=$jib_tag"
        echo "jib_digest=$jib_digest" 
      } > jib.env
    - create_dotenv_file "$jib_digest" "$MAVEN_JIB_RELEASE_IMAGE"
  artifacts:
    reports:
      dotenv: