Skip to content

Commit

Permalink
add ci/cd build docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
sadraiiali committed Apr 22, 2024
1 parent ce87001 commit c1ec850
Show file tree
Hide file tree
Showing 11 changed files with 585 additions and 0 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: ci

on:
push:
branches:
- "master"
tags:
- "*"

env:
BASE_IMAGE: crosslanguagesoccerframework/rcssserver
BASE_TAG: latest

jobs:
docker:
runs-on: ubuntu-latest
name: Build & Push Docker
if: startsWith(github.ref, 'refs/tags/')
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: Find CMakeLists.txt version
id: cmake_version
run: |
cmake_version=$(grep -oP 'project\(.* VERSION \K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt)
echo "::set-output name=version::${cmake_version}"
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- 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-${{ github.ref_name }}-${{ 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
# ------------------------------------------- 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-x86_64-2004.AppImage
# ------------------------------------------- Artifact
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: rcssserver-x86_64
path: ${{ github.workspace }}/artifact/*
retention-days: 5

# ------------------------------------------- Release
- uses: ncipollo/release-action@v1
if: startsWith(github.ref, 'refs/tags/')
with:
artifacts: "${{ github.workspace }}/artifact/*"
token: ${{ secrets.GITHUB_TOKEN }}
# tag text is like "v1.2.3" so we need to remove the "v" from the tag
tag: "${{ github.ref_name }}"
36 changes: 36 additions & 0 deletions utils/appimage/Dockerfile.builder-1804
Original file line number Diff line number Diff line change
@@ -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 <filesystem>/#include <experimental\/filesystem>/g' {} \; && \
find . -type f -name "*.h" -exec sed -i 's/#include <filesystem>/#include <experimental\/filesystem>/g' {} \; && \
find . -type f -name "*.hpp" -exec sed -i 's/#include <filesystem>/#include <experimental\/filesystem>/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 ..
30 changes: 30 additions & 0 deletions utils/appimage/Dockerfile.builder-2004
Original file line number Diff line number Diff line change
@@ -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 ..
24 changes: 24 additions & 0 deletions utils/appimage/Dockerfile.builder-2404
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions utils/appimage/build_appimage.sh
Original file line number Diff line number Diff line change
@@ -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."
8 changes: 8 additions & 0 deletions utils/appimage/build_code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

mkdir build
cd build
cmake -DCMAKE_CXX_STANDARD=17 ..
make
cd ..
14 changes: 14 additions & 0 deletions utils/appimage/rcssserver.desktop
Original file line number Diff line number Diff line change
@@ -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

Binary file added utils/appimage/rcssserver.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions utils/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#------------------------------------------------------
# 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 . /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" ]
43 changes: 43 additions & 0 deletions utils/docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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 add your custom configuration as environment variables, like:
```bash
docker run --name rcssserver --network host -e 'synch_mode=true' -it rcssserver:latest
```
3. 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
Loading

0 comments on commit c1ec850

Please sign in to comment.