pipelines/test/build_image.yaml

130 lines
4.3 KiB
YAML

# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: build-images-
spec:
entrypoint: build-images
volumes:
- name: gcp-credentials
secret:
secretName: user-gcp-sa
arguments:
parameters:
- name: image-build-context-gcs-uri
- name: api-image
- name: frontend-image
- name: scheduledworkflow-image
- name: persistenceagent-image
templates:
- name: build-images
inputs:
parameters:
- name: api-image
- name: frontend-image
- name: scheduledworkflow-image
- name: persistenceagent-image
steps:
- - name: build-api-server-image
template: build-image
arguments:
parameters:
- name: image-build-context-gcs-uri
value: "{{workflow.parameters.image-build-context-gcs-uri}}"
- name: docker-path
value: .
- name: image-name
value: "{{inputs.parameters.api-image}}"
- name: docker-file
value: backend/Dockerfile
- name: build-frontend-image
template: build-image
arguments:
parameters:
- name: image-build-context-gcs-uri
value: "{{workflow.parameters.image-build-context-gcs-uri}}"
- name: docker-path
value: .
- name: docker-file
value: frontend/Dockerfile
- name: image-name
value: "{{inputs.parameters.frontend-image}}"
- name: build-scheduledworkflow-image
template: build-image
arguments:
parameters:
- name: image-build-context-gcs-uri
value: "{{workflow.parameters.image-build-context-gcs-uri}}"
- name: docker-path
value: .
- name: image-name
value: "{{inputs.parameters.scheduledworkflow-image}}"
- name: docker-file
value: backend/Dockerfile.scheduledworkflow
- name: build-persistenceagent-image
template: build-image
arguments:
parameters:
- name: image-build-context-gcs-uri
value: "{{workflow.parameters.image-build-context-gcs-uri}}"
- name: docker-path
value: .
- name: image-name
value: "{{inputs.parameters.persistenceagent-image}}"
- name: docker-file
value: backend/Dockerfile.persistenceagent
# Build image and upload to GCR
- name: build-image
inputs:
parameters:
# GCS URI prefix pointing to a .tar.gz archive of Docker build context
- name: image-build-context-gcs-uri
# The relative code path to the Dockerfile
- name: docker-path
# Name of the Docker file to use. "Dockerfile" by default
- name: docker-file
value: Dockerfile
- name: image-name
outputs:
parameters:
- name: strict-image-name
valueFrom:
path: /outputs/strict-image-name/file
container:
image: gcr.io/ml-pipeline-test/image-builder:v20181128-0.1.3-rc.1-109-ga5a14dc-e3b0c4
imagePullPolicy: 'Always'
args: [
"--image-build-context-gcs-uri", "{{inputs.parameters.image-build-context-gcs-uri}}",
"--docker_path", "{{inputs.parameters.docker-path}}",
"--docker_file", "{{inputs.parameters.docker-file}}",
"--image_name", "{{inputs.parameters.image-name}}",
]
env:
- name: DOCKER_HOST
value: 127.0.0.1
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /secret/gcp-credentials/user-gcp-sa.json
volumeMounts:
- name: gcp-credentials
mountPath: /secret/gcp-credentials
sidecars:
- name: dind
image: docker:17.10-dind
securityContext:
privileged: true
mirrorVolumeMounts: true