-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathdocker-build.sh
More file actions
executable file
·31 lines (24 loc) · 1003 Bytes
/
docker-build.sh
File metadata and controls
executable file
·31 lines (24 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Variables
CONTAINER_NAME="spectator-build"
IMAGE_NAME="spectator-cpp-image"
CONTAINER_FILE_PATH="/home/ubuntu/spectator-cpp/cmake-build"
HOST_FILE_PATH="$PWD"
if [[ -z "$BUILD_TYPE" ]]; then
BUILD_TYPE="Debug"
fi
# Build image if it does not exist
if [[ -z "$(docker images -q $IMAGE_NAME 2>/dev/null)" ]]; then
echo "Docker image $IMAGE_NAME not found. Building..."
docker build -t $IMAGE_NAME -f Dockerfiles/Ubuntu.Dockerfile .
fi
## Remove any previous container
docker rm $CONTAINER_NAME 2>/dev/null || true
## Run the container and execute build.sh inside the virtual environment
docker run --name $CONTAINER_NAME \
--entrypoint bash $IMAGE_NAME -lc \
"source /home/ubuntu/spectator-cpp/venv/bin/activate && set -x && BUILD_TYPE=$BUILD_TYPE bash /home/ubuntu/spectator-cpp/build.sh"
## Copy the build output from the container to the host
docker cp $CONTAINER_NAME:$CONTAINER_FILE_PATH $HOST_FILE_PATH
## Remove the container after copying
docker rm $CONTAINER_NAME