From 1da279d0ed77048e568672ca3e06df7ab55db93c Mon Sep 17 00:00:00 2001
From: Stanislav Riabokon <Stanislav_Riabokon@epam.com>
Date: Fri, 15 Jan 2021 14:30:51 +0400
Subject: [PATCH] Added CloudBuild settings for GCP.

---
 .../cloudbuild/Dockerfile.cloudbuild          | 13 ++++++++
 .../partition-gcp/cloudbuild/cloudbuild.yaml  | 31 +++++++++++++++++++
 2 files changed, 44 insertions(+)
 create mode 100644 provider/partition-gcp/cloudbuild/Dockerfile.cloudbuild
 create mode 100644 provider/partition-gcp/cloudbuild/cloudbuild.yaml

diff --git a/provider/partition-gcp/cloudbuild/Dockerfile.cloudbuild b/provider/partition-gcp/cloudbuild/Dockerfile.cloudbuild
new file mode 100644
index 000000000..be26a65b0
--- /dev/null
+++ b/provider/partition-gcp/cloudbuild/Dockerfile.cloudbuild
@@ -0,0 +1,13 @@
+# Use the official AdoptOpenJDK for a base image.
+# https://hub.docker.com/_/openjdk
+FROM openjdk:8-slim
+WORKDIR /app
+ARG PROVIDER_NAME
+ENV PROVIDER_NAME $PROVIDER_NAME
+ARG PORT
+ENV PORT $PORT
+# Copy the jar to the production image from the builder stage.
+COPY provider/partition-${PROVIDER_NAME}/target/partition-${PROVIDER_NAME}-*-spring-boot.jar partition-${PROVIDER_NAME}.jar
+# Run the web service on container startup.
+CMD java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${PORT} -jar /app/partition-${PROVIDER_NAME}.jar
+
diff --git a/provider/partition-gcp/cloudbuild/cloudbuild.yaml b/provider/partition-gcp/cloudbuild/cloudbuild.yaml
new file mode 100644
index 000000000..c8c28a715
--- /dev/null
+++ b/provider/partition-gcp/cloudbuild/cloudbuild.yaml
@@ -0,0 +1,31 @@
+# Copyright 2021 Google LLC
+# Copyright 2017-2019, Schlumberger
+# Copyright 2021 EPAM
+#
+# 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.
+
+steps:
+  - name: 'gcr.io/cloud-builders/docker'
+    args: [
+            'build',
+            '--build-arg', 'PROVIDER_NAME=${_PROVIDER_NAME}',
+            '--build-arg', 'PORT=${_PORT}',
+            '-t', 'gcr.io/$PROJECT_ID/${_APPLICATION_NAME}/${_GCP_SERVICE}-${_PROVIDER_NAME}:${_SHORT_SHA}',
+            '-t', 'gcr.io/$PROJECT_ID/${_APPLICATION_NAME}/${_GCP_SERVICE}-${_PROVIDER_NAME}:latest',
+            '-f', 'provider/${_GCP_SERVICE}-${_PROVIDER_NAME}/cloudbuild/Dockerfile.cloudbuild',
+            '.'
+    ]
+
+images:
+  - 'gcr.io/$PROJECT_ID/${_APPLICATION_NAME}/${_GCP_SERVICE}-${_PROVIDER_NAME}'
+
-- 
GitLab