diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..6d8b9f0b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +Dockerfile +.dockerignore +build \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..f5ee64c2 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,112 @@ +name: ci + +on: + push: + branches: + - "*" + tags: + - "*" + +env: + BASE_IMAGE: sadraiiali/rcssserver + BASE_TAG: latest + RELEASE_PREFIX: "rcssserver-" + +jobs: + + docker: + runs-on: ubuntu-latest + name: Build & Push Docker + if: github.ref == 'refs/heads/master' + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Find CMakeLists.txt version + id: cmake_version + run: | + cmake_version=$(grep -oP 'project\(.* VERSION \K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt) + echo "version=${cmake_version}" >> $GITHUB_OUTPUT + + - name: Build and push RCSSServer + uses: docker/build-push-action@v5 + with: + context: . + file: ./utils/docker/Dockerfile + push: true + tags: "${{ env.BASE_IMAGE }}:latest,${{ env.BASE_IMAGE }}:ubuntu-24-${{ steps.cmake_version.outputs.version }}" + + - name: Docker Hub Description + uses: peter-evans/dockerhub-description@v4 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + repository: ${{ env.BASE_IMAGE }} + readme-filepath: utils/docker/README.md + short-description: "RoboCup Soccer Simulator Server" + + app-image: + runs-on: ubuntu-latest + name: Build AppImage + steps: + - uses: actions/checkout@v4 + + - name: Create release folder + run: | + mkdir -p ${{ github.workspace }}/artifact + + - name: Find CMakeLists.txt version + id: cmake_version + run: | + cmake_version=$(grep -oP 'project\(.* VERSION \K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt) + echo "version=${cmake_version}" >> $GITHUB_OUTPUT + + # ------------------------------------------- Ubuntu 20.04 AppImage + - name: Prepare builder image for 20.04 + run: | + docker build -t builder-image:2004 -f ./utils/appimage/Dockerfile.builder-2004 . + + - name: Build app image on 20.04 + run: | + docker run --privileged --name builder-2004 \ + builder-image:2004 /rcssserver/utils/appimage/build_appimage.sh + docker cp builder-2004:/rcssserver-x86_64.AppImage ${{ github.workspace }}/artifact/rcssserver-${{ steps.cmake_version.outputs.version }}-x86_64.AppImage + + # ------------------------------------------- Artifact + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: rcssserver-x86_64 + path: ${{ github.workspace }}/artifact/* + retention-days: 5 + + - name: Check if there is no release with the same tag + id: check_release + run: | + out=$(curl -s -o /dev/null -w "%{http_code}" https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ steps.cmake_version.outputs.version }}) + echo "release_exists=${out}" >> $GITHUB_OUTPUT + + + # ------------------------------------------- Release + - name: Create Release + if: ${{ steps.check_release.outputs.release_exists == '404' }} + id: create_release + uses: ncipollo/release-action@v1 + with: + artifacts: "${{ github.workspace }}/artifact/rcssserver-${{ steps.cmake_version.outputs.version }}-x86_64.AppImage" + token: ${{ secrets.GITHUB_TOKEN }} + body: "TBD" + name: "${{ env.RELEASE_PREFIX }}${{ steps.cmake_version.outputs.version }}" + tag: ${{ steps.cmake_version.outputs.version }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..57f0ca45 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +build +*.o +*.so +*.a +.vscode/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 098f5030..ea707c3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,9 @@ project(RCSSServer VERSION 18.1.3) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lstdc++fs") + + if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) endif() @@ -34,6 +37,8 @@ check_include_file_cxx("unistd.h" HAVE_UNISTD_H) check_include_file_cxx("poll.h" HAVE_POLL_H) check_include_file_cxx("pwd.h" HAVE_PWD_H) + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake config.h) add_subdirectory(rcss) diff --git a/utils/appimage/Dockerfile.builder-1804 b/utils/appimage/Dockerfile.builder-1804 new file mode 100644 index 00000000..c34733fc --- /dev/null +++ b/utils/appimage/Dockerfile.builder-1804 @@ -0,0 +1,36 @@ +FROM ubuntu:18.04 + +COPY . /rcssserver + +RUN apt-get clean && apt-get update --allow-insecure-repositories && \ + DEBIAN_FRONTEND="noninteractive" apt-get -y install \ + tzdata \ + gcc \ + g++ \ + wget \ + libfl-dev \ + flex \ + bison \ + libboost-all-dev \ + automake \ + make \ + cmake \ + iputils-ping \ + build-essential \ + libtool \ + fuse \ + libfuse-dev \ + zlib1g-dev + +RUN cd /rcssserver && \ + find . -type f -name "*.cpp" -exec sed -i 's/#include /#include /g' {} \; && \ + find . -type f -name "*.h" -exec sed -i 's/#include /#include /g' {} \; && \ + find . -type f -name "*.hpp" -exec sed -i 's/#include /#include /g' {} \; && \ + find . -type f -name "*.cpp" -exec sed -i 's/std::filesystem/std::experimental::filesystem/g' {} \; && \ + find . -type f -name "*.h" -exec sed -i 's/std::filesystem/std::experimental::filesystem/g' {} \; && \ + find . -type f -name "*.hpp" -exec sed -i 's/std::filesystem/std::experimental::filesystem/g' {} \; && \ + mkdir build && \ + cd build && \ + cmake .. && \ + make && \ + cd .. \ No newline at end of file diff --git a/utils/appimage/Dockerfile.builder-2004 b/utils/appimage/Dockerfile.builder-2004 new file mode 100644 index 00000000..91035f26 --- /dev/null +++ b/utils/appimage/Dockerfile.builder-2004 @@ -0,0 +1,30 @@ +FROM ubuntu:20.04 + +COPY . /rcssserver + +RUN apt-get clean && apt-get update --allow-insecure-repositories && \ + DEBIAN_FRONTEND="noninteractive" apt-get -y install \ + tzdata \ + gcc \ + g++ \ + wget \ + libfl-dev \ + flex \ + bison \ + libboost-all-dev \ + automake \ + make \ + cmake \ + iputils-ping \ + build-essential \ + libtool \ + fuse \ + libfuse-dev \ + zlib1g-dev + +RUN cd /rcssserver && \ + mkdir build && \ + cd build && \ + cmake .. && \ + make && \ + cd .. diff --git a/utils/appimage/Dockerfile.builder-2404 b/utils/appimage/Dockerfile.builder-2404 new file mode 100644 index 00000000..73de5c1d --- /dev/null +++ b/utils/appimage/Dockerfile.builder-2404 @@ -0,0 +1,24 @@ +FROM ubuntu:24.04 + +COPY . /rcssserver + +RUN apt-get clean && apt-get update --allow-insecure-repositories && \ + DEBIAN_FRONTEND="noninteractive" apt-get -y install \ + tzdata \ + gcc \ + g++ \ + wget \ + libfl-dev \ + flex \ + bison \ + libboost-all-dev \ + automake \ + make \ + cmake \ + iputils-ping \ + build-essential \ + libtool \ + fuse \ + libfuse-dev + +RUN cd /rcssserver && ./utils/appimage/build_code.sh \ No newline at end of file diff --git a/utils/appimage/build_appimage.sh b/utils/appimage/build_appimage.sh new file mode 100755 index 00000000..6bd2b776 --- /dev/null +++ b/utils/appimage/build_appimage.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -e + +wget -c "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" -O linuxdeploy-x86_64.AppImage +chmod +x linuxdeploy-x86_64.AppImage +mkdir rcssserver-x86_64 + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +BUILD_PWD="${SCRIPT_DIR}/../../build" +APP_IMAGE_DIR="${SCRIPT_DIR}" + + +# find libc and libstdc++ libz dependencies +LIBSTDCPP_PATH=$(ldd $BUILD_PWD/rcssserver | grep libstdc++ | awk '{ print $3 }') +LIBZ_PATH=$(ldd $BUILD_PWD/rcssserver | grep libz.so | awk '{ print $3 }') +LIBRCSSCLANGPARSER_PATH=$(ldd $BUILD_PWD/rcssserver | grep librcssclangparser.so | awk '{ print $3 }') +LIBRCSSCONFPARSER_PATH=$(ldd $BUILD_PWD/rcssserver | grep librcssconfparser.so | awk '{ print $3 }') +LIBRCSSGZ_PATH=$(ldd $BUILD_PWD/rcssserver | grep librcssgz.so | awk '{ print $3 }') +LIBRCSSNET_PATH=$(ldd $BUILD_PWD/rcssserver | grep librcssnet.so | awk '{ print $3 }') + +echo "LIBSTDCPP_PATH=" $LIBSTDCPP_PATH +echo "LIBZ_PATH=" $LIBZ_PATH +echo "LIBRCSSCLANGPARSER_PATH=" $LIBRCSSCLANGPARSER_PATH +echo "LIBRCSSCONFPARSER_PATH=" $LIBRCSSCONFPARSER_PATH +echo "LIBRCSSGZ_PATH=" $LIBRCSSGZ_PATH +echo "LIBRCSSNET_PATH=" $LIBRCSSNET_PATH + +./linuxdeploy-x86_64.AppImage --appdir ./rcssserver-x86_64 \ + -e $BUILD_PWD/rcssserver \ + -l $LIBRCSSCLANGPARSER_PATH \ + -l $LIBRCSSCONFPARSER_PATH \ + -l $LIBRCSSGZ_PATH \ + -l $LIBRCSSNET_PATH \ + -l $LIBSTDCPP_PATH \ + -l $LIBZ_PATH \ + -d $APP_IMAGE_DIR/rcssserver.desktop \ + -i $APP_IMAGE_DIR/rcssserver.png \ + --output appimage +echo "App Image Created." diff --git a/utils/appimage/build_code.sh b/utils/appimage/build_code.sh new file mode 100755 index 00000000..01236968 --- /dev/null +++ b/utils/appimage/build_code.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +mkdir build +cd build +cmake -DCMAKE_CXX_STANDARD=17 .. +make +cd .. \ No newline at end of file diff --git a/utils/appimage/rcssserver.desktop b/utils/appimage/rcssserver.desktop new file mode 100644 index 00000000..5d011484 --- /dev/null +++ b/utils/appimage/rcssserver.desktop @@ -0,0 +1,14 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Name=rcssserver +Comment=Robocup 2D Soccer Simulation Server +TryExec=rcssserver +Exec=rcssserver +Icon=rcssserver +MimeType=image/x-foo; +Categories=Development; +X-KDE-Library=librcssserver +X-KDE-FactoryName=rcssserverfactory +X-KDE-ServiceType=RcssserverService + diff --git a/utils/appimage/rcssserver.png b/utils/appimage/rcssserver.png new file mode 100644 index 00000000..2c29a896 Binary files /dev/null and b/utils/appimage/rcssserver.png differ diff --git a/utils/docker/Dockerfile b/utils/docker/Dockerfile new file mode 100644 index 00000000..e8912e7e --- /dev/null +++ b/utils/docker/Dockerfile @@ -0,0 +1,60 @@ +#------------------------------------------------------ +# build stage +#------------------------------------------------------ + +FROM ubuntu:24.04 AS BUILD + +WORKDIR /rcssserver + +# set environment variables +ENV config_file=server.conf \ + DATE_FORMAT="%Y%m%d%H%M%S" \ + VERSION=18.1.3 + + +# install dependencies +RUN apt-get clean && apt-get update --allow-insecure-repositories && \ + DEBIAN_FRONTEND="noninteractive" apt-get -y install \ + tzdata \ + sudo \ + gcc \ + g++ \ + wget \ + flex \ + bison \ + libboost-all-dev \ + automake \ + make \ + cmake \ + iputils-ping + +# copy rcssserver source code +#COPY [ "./src", "./rcss", "./m4", "config*","Make*" , "CMake*", "/rcssserver/"] +COPY . /rcssserver/ + +# make and install rcssserver +RUN cd /rcssserver/ \ + && ./bootstrap \ + && ./configure --prefix=`pwd`/server-bin \ + && make \ + && make install \ + && ldconfig + + + + +#------------------------------------------------------ +# run stage +#------------------------------------------------------ +FROM ubuntu:24.04 AS RUN + +ENV LD_LIBRARY_PATH=/app/server-bin/lib:/usr/local/lib:/usr/lib:/lib \ + PATH=/app/server-bin/bin:$PATH + +WORKDIR /app + +COPY --from=BUILD /rcssserver/server-bin /app/server-bin + +COPY utils/docker/docker-entrypoint.sh /app/docker-entrypoint.sh + +CMD [ "bash", "/app/docker-entrypoint.sh" ] \ No newline at end of file diff --git a/utils/docker/README.md b/utils/docker/README.md new file mode 100644 index 00000000..af9d7d1b --- /dev/null +++ b/utils/docker/README.md @@ -0,0 +1,39 @@ +# RoboCup Soccer Simulator Server +This image contains the RoboCup Soccer Simulator Server (rcssserver) installed and ready to use. + +## Tags +- latest + +## How to use this image + +Run the following command to start the server: +```bash +docker run --name rcssserver --network host -it rcssserver:latest +``` +Now you can connect to the server using the monitor or a client. + +## How to use custom configuration files +1. You can mount a volume with your custom configuration files, like: +```bash +docker run --name rcssserver --network host -v /path/to/your/configs:/root/.rcssserver -it rcssserver:latest +``` +2. You can run server with custom command line arguments, like: +```bash +docker run --name rcssserver --network host -it rcssserver:latest rcssserver server::synch_mode=true + +``` + + +**Note**: You can either use one of the above methods at a time. +It means: +* if there is a server configuration file environment variable will be ignored. +* if you use third method, the second method will be ignored. + + + +## :incoming_envelope: Contributing + +For bug reports, feature requests and latest updates, please goto +https://github.com/rcsoccersim/rcssserver and open an issue or a pull request. + +> The RoboCup Soccer Server Maintainance Group diff --git a/utils/docker/docker-entrypoint.sh b/utils/docker/docker-entrypoint.sh new file mode 100755 index 00000000..29eaed28 --- /dev/null +++ b/utils/docker/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/env bash + +SERVER_CONFIG_FOLDER='/root/.rcssserver' +LOGS_FOLDER='/root/rcssserver-logs' + +mkdir -p $LOGS_FOLDER +cd $LOGS_FOLDER + +rcssserver + +