Build your own Docker Image

Build your own custom Docker Image of HyperTest

HyperTest's docker images uses node:20-bookworm-slim as a base docker image. If you want to use your own node image as base image for HyperTest, you can do so and rebuild the image with the following script.

To build your own custom image follow the steps given in this page

  1. Create the file named docker-image-HT-script.sh

docker-image-HT-script.sh
#!/bin/bash

# Load environment variables from .env file
if [ -f .env ]; then
    export $(cat .env | grep -v ^# | xargs)
fi

# Clone the git repo
git clone https://${GIT_FT_PAT}@github.com/hypertestco/v2-artifacts.git

# Navigate into the cloned repository
cd v2-artifacts || exit

# Checkout to version of HT
git checkout ${HYPERTEST_VERSION}

# Function to parse dependenciesVersion.txt and extract version numbers
parse_dependencies() {
    local file="dependenciesVersion.txt"
    if [ -f "$file" ]; then
        prismaEngVersion=$(grep -E "^prismaEngVersion:" "$file" | sed 's/prismaEngVersion://' | tr -d '[:space:]')
        bcryptVersion=$(grep -E "^bcryptVersion:" "$file" | sed 's/bcryptVersion://' | tr -d '[:space:]')
    else
        echo "Error: dependenciesVersion.txt not found"
        exit 1
    fi
}

# Parse dependenciesVersion.txt to extract version numbers
parse_dependencies

# Build Docker image
docker build -t ${DOCKER_IMAGE_NAME} \
             --build-arg NODE_BASE_IMAGE=${NODE_BASE_IMAGE} \
             --build-arg PRIMSA_ENG_PKG_VERSION=${PRIMSA_ENG_PKG_VERSION} \
             --build-arg BCRYPT_VERSION=${BCRYPT_VERSION} .
  1. Create the file named .env

.env
GIT_FT_PAT=<Fine_grained_PAT_received from HT Team(diff than NPM)>
HYPERTEST_VERSION=<Get the latest version from HT team>
DOCKER_IMAGE_NAME=<c_docker_image_name>
NODE_BASE_IMAGE=<Node_base_image, we are using node:20-bookworn-slim>
  1. Update the auth token, docker image name and node base image in .env file

  2. Run the script using below command

sh  docker-image-HT-script.sh

The above script will do the following steps

  1. Clone the rsitory containing docker artifacts

  2. Fetch package versions from repo content for a few packages required to run HT

  3. Build a docker image based on the name and base image you passed in .env file

NOTE: The base image should have node (version 20 as of now) and npm installed in it

Last updated