Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 1d754ce

Browse files
Merge pull request #259 from jim-deriv/Jim/FEQ-878/setup-docker-and-kubernetes
FEQ-878 / add docker and k8s setup
2 parents a786f4b + 90be40d commit 1d754ce

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: k8s_deploy
2+
description: Deploy to Kubernetes
3+
inputs:
4+
K8S_VERSION:
5+
description: Kubernetes version
6+
required: true
7+
type: string
8+
K8S_NAMESPACE:
9+
description: Kubernetes namespace
10+
required: false
11+
type: string
12+
default: 'deriv-com-api-staging'
13+
CA_CRT:
14+
description: Kubernetes CA certificate
15+
required: true
16+
type: string
17+
steps:
18+
- k8s/install-kubectl
19+
- run:
20+
name: Deploying to k8s cluster for service ${{ inputs.K8S_NAMESPACE }} 🚀
21+
command: |
22+
export NAMESPACE=${{ inputs.K8S_NAMESPACE }}
23+
git clone https://github.com/binary-com/devops-ci-scripts
24+
cd devops-ci-scripts/k8s-build_tools
25+
echo ${{ inputs.CA_CRT }} | base64 --decode > ca.crt
26+
export CA="ca.crt"
27+
./release.sh deriv-com-api ${{ inputs.K8S_VERSION }}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: docker_build_push
2+
description: Build and push Docker image to Docker Hub
3+
inputs:
4+
DOCKER_LATEST_IMAGE_TAG:
5+
description: Docker image tag
6+
required: false
7+
default: 'latest-staging'
8+
type: string
9+
DOCKER_IMAGE_TAG:
10+
description: Docker image tag
11+
required: true
12+
type: string
13+
DOCKERHUB_ORGANISATION:
14+
description: Docker Hub organisation
15+
required: true
16+
type: string
17+
DOCKERHUB_USERNAME:
18+
description: Docker Hub username
19+
required: true
20+
type: string
21+
DOCKERHUB_PASSWORD:
22+
description: Docker Hub password
23+
required: true
24+
type: string
25+
steps:
26+
- setup_remote_docker
27+
- run:
28+
name: Building docker image 🐳
29+
command: |
30+
docker build -t ${{ inputs.DOCKERHUB_ORGANISATION }}/deriv-com-api:${{ inputs.DOCKER_IMAGE_TAG }} -t ${{ inputs.DOCKERHUB_ORGANISATION }}/deriv-com-api:${{ inputs.DOCKER_LATEST_IMAGE_TAG }} .
31+
- name: Verify nginx image
32+
run: |
33+
set -e
34+
docker run --rm ${{ inputs.DOCKERHUB_ORGANISATION }}/deriv-com-api:${{ inputs.DOCKER_LATEST_IMAGE_TAG }} nginx -t
35+
echo "docker image validated successfully"
36+
- run:
37+
name: Pushing Image to docker hub 🐳
38+
command: |
39+
echo ${{ inputs.DOCKERHUB_PASSWORD }} | docker login -u $${{ inputs.DOCKERHUB_USERNAME }} --password-stdin
40+
docker push ${{ inputs.DOCKERHUB_ORGANISATION }}/deriv-com-api:${{ inputs.DOCKER_IMAGE_TAG }}
41+
docker push ${{ inputs.DOCKERHUB_ORGANISATION }}/deriv-com-api:${{ inputs.DOCKER_LATEST_IMAGE_TAG }}

.github/workflows/release_production.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ jobs:
3333
with:
3434
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
3535
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
36+
- name: Publish to Docker
37+
uses: ./.github/actions/publish_to_docker
38+
with:
39+
DOCKER_LATEST_IMAGE_TAG: 'latest'
40+
DOCKER_IMAGE_TAG: ${{ secrets.SHA1 }}
41+
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }}
42+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
43+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
44+
- name: Deploy to Kubernetes
45+
uses: ./.github/actions/deploy_to_kubernetes
46+
with:
47+
K8S_VERSION: ${{ github.ref_name }}
48+
K8S_NAMESPACE: 'deriv-com-api-production'
49+
CA_CRT: ${{ secrets.CA_CRT }}
3650
send_slack_notification:
3751
name: Send Slack Notification
3852
environment: Production

.github/workflows/release_staging.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,17 @@ jobs:
2626
with:
2727
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
2828
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
29+
- name: Publish to Docker
30+
uses: ./.github/actions/publish_to_docker
31+
with:
32+
DOCKER_LATEST_IMAGE_TAG: 'latest-staging'
33+
DOCKER_IMAGE_TAG: ${{ secrets.SHA1 }}
34+
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }}
35+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
36+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
37+
- name: Deploy to Kubernetes
38+
uses: ./.github/actions/deploy_to_kubernetes
39+
with:
40+
K8S_VERSION: ${{ github.ref_name }}
41+
K8S_NAMESPACE: 'deriv-com-api-staging'
42+
CA_CRT: ${{ secrets.CA_CRT }}

0 commit comments

Comments
 (0)