Skip to content

Commit

Permalink
Merge pull request #586 from yaswanth-deriv/yaswanth/FEQ-951_smarttra…
Browse files Browse the repository at this point in the history
…der-dockerk8s-setup

Yaswanth/feq 951 smarttrader dockerk8s setup
  • Loading branch information
balakrishna-deriv authored Dec 14, 2023
2 parents 5c27f3c + 63103bb commit f5d9e05
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/actions/build_and_push_docker_image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: build_and_push_docker_image_and_k8s
description: Build docker image and push to docker hub and K8S
inputs:
DOCKERHUB_ORGANISATION:
description: "Dockerhub Organisation"
required: true
DOCKERHUB_USERNAME:
description: "Dockerhub Username"
required: true
DOCKERHUB_PASSWORD:
description: "Dockerhub Password"
required: true
K8S_NAMESPACE:
description: "K8S namespace"
required: true
K8S_SERVICE:
description: "K8S service"
required: true
KUBE_SERVER:
description: "K8S server"
required: true
SERVICEACCOUNT_TOKEN:
description: "K8S service account token"
required: true
CA_CRT:
description: "K8S CA_CRT"
required: true
APP_VERSION:
description: "App version"
required: true
runs:
using: composite
steps:
- name: Setup Environment variables
run: |
echo "NAMESPACE=${{ inputs.K8S_NAMESPACE }}" >> "$GITHUB_ENV"
echo "KUBE_SERVER=${{ inputs.KUBE_SERVER }}" >> "$GITHUB_ENV"
echo "SERVICEACCOUNT_TOKEN=${{ inputs.SERVICEACCOUNT_TOKEN }}" >> "$GITHUB_ENV"
echo "DOCKERHUB_ORGANISATION=${{ inputs.DOCKERHUB_ORGANISATION }}" >> "$GITHUB_ENV"
echo "CA_CRT=${{ inputs.CA_CRT }}" >> "$GITHUB_ENV"
echo "APP_NAME=deriv-binary-static" >> "$GITHUB_ENV"
echo "APP_VERSION=${{ inputs.APP_VERSION }}" >> "$GITHUB_ENV"
shell: bash
- name: Build docker image 🐳
run: docker build -t ${DOCKERHUB_ORGANISATION}/${APP_NAME}:${APP_VERSION} -t ${DOCKERHUB_ORGANISATION}/${APP_NAME}:${{ github.ref_name }} .
shell: bash
- name: Verify nginx image
run: |
set -e
docker run --rm ${DOCKERHUB_ORGANISATION}/${APP_NAME}:${{ github.ref_name }} nginx -t
echo "docker image validated successfully"
shell: bash
- name: Pushing Image to docker hub 🐳
run: |
echo ${{ inputs.DOCKERHUB_PASSWORD }}| docker login -u ${{ inputs.DOCKERHUB_USERNAME }} --password-stdin
docker push ${DOCKERHUB_ORGANISATION}/${APP_NAME}:${APP_VERSION}
docker push ${DOCKERHUB_ORGANISATION}/${APP_NAME}:${{ github.ref_name }}
shell: bash
- name: Deploy 🚀
run: |
git clone https://github.com/binary-com/devops-ci-scripts
cd devops-ci-scripts/k8s-build_tools
echo $CA_CRT | base64 --decode > ca.crt
export CA="ca.crt"
./release.sh ${APP_NAME} ${{ github.ref_name }}
shell: bash
11 changes: 11 additions & 0 deletions .github/workflows/release_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ jobs:
with:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- name: Build Docker image and push to Docker hub and K8S
uses: "./.github/actions/build_and_push_docker_image"
with:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }}
K8S_NAMESPACE: binary-static-production
KUBE_SERVER: ${{ secrets.KUBE_SERVER }}
SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }}
CA_CRT: ${{ secrets.CA_CRT }}
APP_VERSION: latest

notify_on_slack:
name: Notify on Slack
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/release_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,14 @@ jobs:
with:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- name: Build Docker image and push to Docker hub and K8S
uses: "./.github/actions/build_and_push_docker_image"
with:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }}
K8S_NAMESPACE: binary-static-staging
KUBE_SERVER: ${{ secrets.KUBE_SERVER }}
SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }}
CA_CRT: ${{ secrets.CA_CRT }}
APP_VERSION: latest-staging

0 comments on commit f5d9e05

Please sign in to comment.