Skip to content
This repository was archived by the owner on Feb 15, 2022. It is now read-only.
This repository was archived by the owner on Feb 15, 2022. It is now read-only.

spk service create should allow for arguments to be passed into the az acr build process #1006

@jmspring

Description

@jmspring

As a: developer

I want: to be able to pass arguments into the container build process.

Describe the solution you'd like:

Building of the Dockerfile assumes there are no inputs into the build process. One possible example would be to add a variable group and script the inputs to generate the build are string.

An example of doing such is as follows:

          - script: |-
              set -e
              export BUILD_REPO_NAME=$(echo $(Build.Repository.Name)-jmsgumbo-svc | tr '[:upper:]' '[:lower:]')
              echo "Image Name: $BUILD_REPO_NAME"
              cd ./
              echo "az acr build -r $(ACR_NAME) --image $BUILD_REPO_NAME:$(echo $(Build.SourceBranchName) | tr / - | tr . -)-$(Build.BuildNumber) ."
              az acr build -r $(ACR_NAME) --image $BUILD_REPO_NAME:$(echo $(Build.SourceBranchName) | tr / - | tr . -)-$(Build.BuildNumber) .
            displayName: ACR Build and Publish

To:

          - script: |-
              set -e
              export BUILD_REPO_NAME=$(echo $(Build.Repository.Name)- | tr '[:upper:]' '[:lower:]')
              echo "Image Name: $BUILD_REPO_NAME"
              cd ./
              export DOCKER_BUILD_FILE=$(if [ -z "$SERVICE_DOCKERFILE_PATH" ]; then echo "DockerFile"; else echo "$SERVICE_DOCKERFILE_PATH"; fi)
              if [ ! -z "$SERVICE_NAME_BASE" ]; then
                arg_str=""
                for v in project_path version_suffix test_logger skip_tests docker_entrypoint framework_release framework_build; do
                arg_str=""
                for v in project_path version_suffix test_logger skip_tests docker_entrypoint framework_release framework_build; do
                  valueKey=$(echo "service_""$v" | tr '[:lower:]' '[:upper:]')
                  arg_str="$arg_str --build-arg $v=\"${!valueKey}\""
                done
              fi
              echo "az acr build -r $(ACR_NAME) --file $DOCKER_BUILD_FILE $arg_str --image $BUILD_REPO_NAME:$(Build.SourceBranchName)-$(Build.BuildNumber) ."
              az acr build -r $(ACR_NAME) --file $DOCKER_BUILD_FILE $arg_str --image $BUILD_REPO_NAME:$(Build.SourceBranchName)-$(Build.BuildNumber) .
            displayName: ACR Build and Publish

Acceptance Criteria:

  • Design documentation on implementation
  • A flag to add a variable-group and a list of variables to be used as build args during spk service create
  • Enforcing variable name cases:
  • Command to create a new variable-group in azure devops with given variables and values (some of which will be secrets).
    • does spk variable-group create do what we need already?
      • We may be deprecating that command. For now we'll link documentation and guidance on how to manually create variable groups though the az cli or UI.
  • reference documentation on bedrock repository during walkthrough components
  • updated smoke tests with build arguments

Does this require updates to documentation?:
Yes

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions