From 8de3eff1fa32cb05572dcfb559ba560917b04730 Mon Sep 17 00:00:00 2001 From: Christian Geller Date: Thu, 1 Feb 2024 16:41:50 +0100 Subject: [PATCH 1/6] add create-carla-client-image workflow job --- .github/workflows/docker.yml | 43 ++++++++++++++++++---- Util/Docker/client/Client.Dockerfile | 54 ++++++++++++++++++++++++++++ Util/Docker/client/entrypoint.sh | 8 +++++ 3 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 Util/Docker/client/Client.Dockerfile create mode 100644 Util/Docker/client/entrypoint.sh diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e372a0f2ac4..213fa40ece9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -113,11 +113,42 @@ jobs: artifacts: artifacts/PythonAPI.tar.gz token: ${{ secrets.PAT }} - # create vulkan-base for carla release + # create carla client image + create-carla-client-image: + name: Create carla client image + runs-on: self-hosted + needs: provide-artifacts + env: + IMAGE_TAG_SUFFIX: "" + + steps: + + - name: Set image tag + run: | + echo "IMAGE_TAG_SUFFIX=_$(echo '${{ github.ref_name }}' | tr / -)_ci" >> $GITHUB_ENV + if: github.ref_name != github.event.repository.default_branch + + - uses: docker/login-action@v3 + name: Login to Docker Hub + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - uses: docker/build-push-action@v5 + name: Build and push image + with: + file: Util/Docker/client/Client.Dockerfile + tags: rwthika/carla-simulator:client${{env.IMAGE_TAG_SUFFIX}} + no-cache: true + build-args: | + UBUNTU_VERSION=22.04 + context: . + + # create vulkan-base for carla server image create-vulkan-base-image: name: Create vulkan-base image runs-on: self-hosted - needs: provide-artifacts + needs: create-carla-client-image steps: - uses: docker/build-push-action@v5 @@ -131,9 +162,9 @@ jobs: CUDA_VERSION=12.2.0 context: Util/Docker/vulkan-base - # create and push carla image - create-carla-image: - name: Create carla image + # create and push carla server image + create-carla-server-image: + name: Create carla server image runs-on: self-hosted needs: create-vulkan-base-image env: @@ -159,7 +190,7 @@ jobs: name: Build and push with: file: build/Dockerfile - tags: rwthika/carla-simulator:latest${{env.IMAGE_TAG_SUFFIX}} + tags: rwthika/carla-simulator:server${{env.IMAGE_TAG_SUFFIX}} no-cache: true context: build push: true diff --git a/Util/Docker/client/Client.Dockerfile b/Util/Docker/client/Client.Dockerfile new file mode 100644 index 00000000000..bc69c5f7876 --- /dev/null +++ b/Util/Docker/client/Client.Dockerfile @@ -0,0 +1,54 @@ +ARG UBUNTU_VERSION="22.04" + +FROM "ubuntu:${UBUNTU_VERSION}" as dependencies + +USER root +SHELL ["/bin/bash", "-c"] + +ARG CARLA_API_PATH=/opt/carla/PythonAPI + +# Install essentials +RUN apt-get update && \ + apt-get install -y \ + fontconfig \ + x11-apps \ + python3-pip \ + libomp5 \ + libjpeg-turbo8 libtiff-dev \ + libgeos-dev \ + && rm -rf /var/lib/apt/lists/* + +RUN pip3 install --upgrade pip +RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10 + +# Move over PythonAPI +COPY ./artifacts/PythonAPI ${CARLA_API_PATH} + +# Recursively install PythonAPI requirements, keep version of first occurrence +RUN cat $(find ${CARLA_API_PATH} -type f -name "requirements.txt") > /tmp/requirements_raw.txt \ + && awk -F '==' '{print $1}' /tmp/requirements_raw.txt | awk '!visited[$1]++' > /tmp/requirements.txt \ + && pip3 install -r /tmp/requirements.txt + +# Create script that adds API to pythonpath and make .bashrc source it +RUN echo "export PYTHONPATH=\$PYTHONPATH:$CARLA_API_PATH/carla/dist/$(ls $CARLA_API_PATH/carla/dist | grep py$(python --version | awk -F'[ .]' '{print $2"."$3}').)" >> /setup_carla_env.sh; \ + echo "export PYTHONPATH=\$PYTHONPATH:$CARLA_API_PATH/carla/agents" >> /setup_carla_env.sh; \ + echo "export PYTHONPATH=\$PYTHONPATH:$CARLA_API_PATH/carla" >> /setup_carla_env.sh; \ + echo "export CARLA_API_PATH=$CARLA_API_PATH" >> /setup_carla_env.sh; \ + echo "source /setup_carla_env.sh" >> ~/.bashrc + + +# Needed for (pygame based) scripts that have a GUI +ENV SDL_VIDEODRIVER=x11 + +USER root +SHELL ["/bin/bash", "-c"] + +ARG WORKSPACE=${CARLA_API_PATH} +ENV WORKSPACE=${WORKSPACE} +WORKDIR ${WORKSPACE} + +# Set entrypoint +COPY ./Util/Docker/client/entrypoint.sh / +ENTRYPOINT [ "/entrypoint.sh" ] + +CMD [ "python3", "util/test_connection.py" ] diff --git a/Util/Docker/client/entrypoint.sh b/Util/Docker/client/entrypoint.sh new file mode 100644 index 00000000000..f546ece4e34 --- /dev/null +++ b/Util/Docker/client/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +# source CARLA environment setup script +source /setup_carla_env.sh + +# run the actual command +exec "$@" From 48d4347905c25dc678036aaa69b8c5a0d9eb012a Mon Sep 17 00:00:00 2001 From: Christian Geller <88664444+cgeller@users.noreply.github.com> Date: Thu, 1 Feb 2024 23:57:50 +0100 Subject: [PATCH 2/6] Add push to client image --- .github/workflows/docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 213fa40ece9..6559e27b04a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -143,6 +143,7 @@ jobs: build-args: | UBUNTU_VERSION=22.04 context: . + push: true # create vulkan-base for carla server image create-vulkan-base-image: From cfc3862fb66cbb1e55926c9d2ec7005b33a0c134 Mon Sep 17 00:00:00 2001 From: Christian Geller <88664444+cgeller@users.noreply.github.com> Date: Thu, 1 Feb 2024 23:58:30 +0100 Subject: [PATCH 3/6] Add push to source stage --- .github/workflows/docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 6559e27b04a..e74d6ff3625 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -64,6 +64,7 @@ jobs: no-cache: true push: false context: . + push: true # provide artifacts and releases provide-artifacts: From be1367feca55a71326c09e93c0533dd1500a9cab Mon Sep 17 00:00:00 2001 From: Christian Geller <88664444+cgeller@users.noreply.github.com> Date: Fri, 2 Feb 2024 00:26:08 +0100 Subject: [PATCH 4/6] Fix syntax --- .github/workflows/docker.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e74d6ff3625..88e672a783d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -62,7 +62,6 @@ jobs: file: Util/Docker/Carla.Dockerfile tags: rwthika/carla-simulator:source${{env.IMAGE_TAG_SUFFIX}} no-cache: true - push: false context: . push: true From 4a70aed962d4499266922041e8fe888dcecb39d6 Mon Sep 17 00:00:00 2001 From: Christian Geller Date: Fri, 2 Feb 2024 09:30:37 +0100 Subject: [PATCH 5/6] change file mod of entrypoint.sh --- Util/Docker/client/entrypoint.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 Util/Docker/client/entrypoint.sh diff --git a/Util/Docker/client/entrypoint.sh b/Util/Docker/client/entrypoint.sh old mode 100644 new mode 100755 From fc683e97b7e52128c10e6da16ead578113288064 Mon Sep 17 00:00:00 2001 From: Christian Geller <88664444+cgeller@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:44:50 +0100 Subject: [PATCH 6/6] Update CARLOS_CHANGELOG.md --- CARLOS_CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CARLOS_CHANGELOG.md b/CARLOS_CHANGELOG.md index 8bd7c3b2dbe..0654bcfc30a 100644 --- a/CARLOS_CHANGELOG.md +++ b/CARLOS_CHANGELOG.md @@ -8,6 +8,7 @@ * Update to Ubuntu 22.04 and Python 3.10 for prerequisites image * Update to Ubuntu 22.04 and Python 3.10 for release image * Created `vulkan-base` Dockerfile to replace discontinued `nvidia/vulkan` images used for the release image +* Created `client` Dockerfile to provide PythonAPI client image * Added health check to release image ### Minor changes