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 "$@"