Automating Action Server Image Builds in gitlab

I saw code for automating action server build in RASA documentation

      - main
    - 'actions/**'

    runs-on: ubuntu-latest
    name: Build Action Server image and upgrade Rasa X deployment
    - name: Checkout repository
      uses: actions/checkout@v2

    - id: action_server
      name: Build an action server with a custom actions
      uses: RasaHQ/action-server-gha@master
      # Full list of parameters:
        docker_image_name: 'account_username/repository_name'
        docker_registry_login: ${{ secrets.DOCKER_HUB_LOGIN }}
        docker_registry_password: ${{ secrets.DOCKER_HUB_PASSWORD }}
        # More details about github context:
        # github.sha - The commit SHA that triggered the workflow run
        docker_image_tag: ${{ github.sha }}

I don’t know much about CI/CD, can someone help me to do the same in gitlab. I am deploying rasa using and trying to automate the deployment process using gitlab CI/CD


@athulvingt Heya! Thanks for the ping. Please give me some time for this use case and if you get some break through please share me the update or even solution.

@athulvingt Are you aware of Github or Gitlab Actions?

        name: rasa/rasa:2.2.7
        entrypoint: [""]

  DOCKER_DRIVER: overlay2
  DOCKER_HOST: tcp://docker:2375

  - docker:dind

  - build 
  - deploy

  stage: build
  image: docker:latest
    - docker build -t $TAG_COMMIT -t $TAG_LATEST .
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
    - docker push $TAG_COMMIT
    - docker push $TAG_LATEST
      - main
        - 'actions/**'
  stage: deploy
  image: alpine:latest
    - chmod og= $ID_RSA
    - apk update && apk add openssh-client
    - ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY"
    - ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker container rm -f rasa_app_1 || true"
    - ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker pull $TAG_LATEST"
    - ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker-compose -f /etc/rasa/docker-compose.override.yml up -d app"

      - main
        - 'actions/**'

this thing worked for me, in override file i am using only the “latest” tag

version: '3.4'
    image: <image>:latest

I am not sure, if this is right, correct me if I am wrong, I referred this post

@athulvingt nice congrts you implemented this process, is this solution only for rasa x or it can be done for rasa open source and Rasa SDK? Athul Suresh please can you provide steps solution when ever you got some time, it will really help other users. I hope you will share. Thanks for the solution :handshake:

I am new to CI/CD, so correct me if I am wrong.

Here I have automated the process of creating an docker image and deploy it when there is any changes in any files in the folder actions, So It can be used for Rasa SDK aswell if your action server is running on docker containers. I followed the RASA X docker, server deployment documentation, if you are using are using it for rasa SDK or manually building docker images assign the ports properly.

My pipeline have two parts one is build and deploy.

  1. Build
  2. Deploy

I am not editing the docker-compose file everytime I create a new docker image for action server, Instead I have a docker-compose.override file like this

I guess these things are necessary to build the image.

I am using the latest tag for image, because i am building the image with latest tag.

During build stage I build two images, one with latest tag and another with a unique id. After pushing these 2 images into registry, the image with unique id will be added to the registry and the image with latest tag replace the earlier image with latest tag. So, if the newly created image doesn’t work properly you can always revert back to the previous image

Deploy Before deploying the image, there are few things you have to do, follow this post to create anew user and to add private-key in gitlab.

Login to the server, here $ID_RSA is the identifier of the private key added to your gitlab.

are the username and server IP, All these identifiers has to be to added in your gitlab variables so that you don’t have to disclose these things in your Ci/CD file.

Removing the running container, here my action server codes are run onth server rasa_app_1

Pulling the new build image with latest tag

the above code will run the docker-compose.override file in the folder /etc/rasa

@athulvingt Thanks for the detail steps Athul. The above solution work for rasa x only right?

You can make it work for RASA SDK as well, CI/CD pipeline will be same. Dockerfile will be different