-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'deploy-bot-live' into 'main'
feat(chat-bot): Change pipeline use Gitlab CI/CD and helm See merge request buycycle/bot!2
- Loading branch information
Showing
4 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
stages: | ||
- build | ||
- deploy | ||
|
||
variables: | ||
AWS_REGION: eu-central-1 | ||
DOCKER_HOST: tcp://docker:2375/ | ||
DOCKER_DRIVER: overlay2 | ||
DOCKER_TLS_CERTDIR: "" | ||
IMAGE_NAME: $CI_PROJECT_NAME | ||
|
||
.build: | ||
stage: build | ||
image: | ||
name: amazon/aws-cli | ||
entrypoint: [""] | ||
services: | ||
- name: docker:dind | ||
entrypoint: ["env", "-u", "DOCKER_HOST"] | ||
command: ["dockerd-entrypoint.sh"] | ||
before_script: | ||
- amazon-linux-extras install docker | ||
- aws --version | ||
- docker --version | ||
script: | ||
- echo "Logging in to AWS ECR" | ||
- aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ECR_REGISTRY | ||
- export TAG=$(echo $CI_COMMIT_SHA | cut -c 1-5) | ||
- export IMAGE_TAG="${ENVIRONMENT}-${TAG}" | ||
- env | grep OPENAI_API_KEY >> rust_bot/.env | ||
- env | grep DATABASE_URL >> rust_bot/.env | ||
- env | grep DATABASE_URL_PROD >> rust_bot/.env | ||
- echo "Build Docker image" | ||
- docker build -f docker/${DOCKERFILE} -t $AWS_ECR_REGISTRY:$IMAGE_TAG . | ||
- echo "Pushing Docker image to ECR" | ||
- docker push $AWS_ECR_REGISTRY:$IMAGE_TAG | ||
|
||
.deploy: | ||
image: | ||
name: alpine/k8s:1.20.15 | ||
entrypoint: ["/bin/sh", "-c"] | ||
before_script: | ||
- export TAG=$(echo $CI_COMMIT_SHA | cut -c 1-5) | ||
- export IMAGE_TAG="${ENVIRONMENT}-${TAG}" | ||
- aws --region $AWS_REGION eks update-kubeconfig --name ${CLUSTER_NAME} | ||
- kubectl version --short | ||
script: | ||
- cd helm/ | ||
- echo "Deploy Bot-${ENVIRONMENT}" | ||
- helm repo add dasmeta https://dasmeta.github.io/helm | ||
- helm upgrade --install chat-bot-${ENVIRONMENT} -n ${NAMESPACE} dasmeta/base --version 0.1.62 -f values.yaml -f values.${ENVIRONMENT}.yaml --set image.tag=$IMAGE_TAG --set labels.label1.value=$IMAGE_TAG | ||
|
||
|
||
build: | ||
extends: .build | ||
rules: | ||
- if: $CI_COMMIT_BRANCH == "main" | ||
variables: | ||
ENVIRONMENT: prod | ||
DOCKERFILE: main.dockerfile | ||
- if: $CI_COMMIT_BRANCH == "dev" | ||
variables: | ||
ENVIRONMENT: dev | ||
DOCKERFILE: dev.dockerfile | ||
|
||
deploy: | ||
extends: .deploy | ||
stage: deploy | ||
rules: | ||
- if: $CI_COMMIT_BRANCH == "main" | ||
variables: | ||
ENVIRONMENT: prod | ||
CLUSTER_NAME: buycycle-cluster | ||
NAMESPACE: live | ||
- if: $CI_COMMIT_BRANCH == "dev" | ||
variables: | ||
ENVIRONMENT: dev | ||
CLUSTER_NAME: buycycle-cluster | ||
NAMESPACE: dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
env: dev | ||
product: bot | ||
|
||
ingress: | ||
enabled: true | ||
class: alb | ||
annotations: | ||
alb.ingress.kubernetes.io/group.name: chat-bot | ||
alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:eu-central-1:930985312118:certificate/91d0862b-63d7-44e5-b133-49780e5d55ee | ||
hosts: | ||
- host: dev.assistant.buycycle.com | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: chat-bot-dev | ||
port: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
env: prod | ||
product: bot | ||
|
||
ingress: | ||
enabled: true | ||
class: alb | ||
annotations: | ||
alb.ingress.kubernetes.io/group.name: chat-bot | ||
alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:eu-central-1:930985312118:certificate/91d0862b-63d7-44e5-b133-49780e5d55ee | ||
hosts: | ||
- host: assistant.buycycle.com | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: chat-bot-prod | ||
port: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
image: | ||
repository: 930985312118.dkr.ecr.eu-central-1.amazonaws.com/chat-bot | ||
pullPolicy: IfNotPresent | ||
# Overrides the image tag whose default is the chart appVersion. | ||
tag: dev-86 | ||
|
||
podAnnotations: | ||
linkerd.io/inject: enabled | ||
|
||
resources: | ||
limits: | ||
memory: "4Gi" | ||
requests: | ||
memory: "1Gi" | ||
|
||
containerPort: 3000 | ||
service: | ||
enabled: true | ||
name: http | ||
type: NodePort | ||
port: 80 | ||
protocol: TCP | ||
annotations: | ||
linkerd.io/inject: enabled | ||
|
||
replicaCount: 2 | ||
labels: | ||
label1: | ||
name: "app-version" | ||
value: "v0.0.1" |