Skip to content

Commit c1ec850

Browse files
committed
add ci/cd build docker image
1 parent ce87001 commit c1ec850

File tree

11 files changed

+585
-0
lines changed

11 files changed

+585
-0
lines changed

.github/workflows/main.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- "master"
7+
tags:
8+
- "*"
9+
10+
env:
11+
BASE_IMAGE: crosslanguagesoccerframework/rcssserver
12+
BASE_TAG: latest
13+
14+
jobs:
15+
docker:
16+
runs-on: ubuntu-latest
17+
name: Build & Push Docker
18+
if: startsWith(github.ref, 'refs/tags/')
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Set up QEMU
24+
uses: docker/setup-qemu-action@v3
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Find CMakeLists.txt version
30+
id: cmake_version
31+
run: |
32+
cmake_version=$(grep -oP 'project\(.* VERSION \K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt)
33+
echo "::set-output name=version::${cmake_version}"
34+
35+
36+
- name: Login to Docker Hub
37+
uses: docker/login-action@v3
38+
with:
39+
username: ${{ secrets.DOCKERHUB_USERNAME }}
40+
password: ${{ secrets.DOCKERHUB_TOKEN }}
41+
42+
- name: Build and push RCSSServer
43+
uses: docker/build-push-action@v5
44+
with:
45+
context: .
46+
file: ./utils/docker/Dockerfile
47+
push: true
48+
tags: "${{ env.BASE_IMAGE }}:latest,${{ env.BASE_IMAGE }}:ubuntu-24-${{ github.ref_name }}-${{ steps.cmake_version.outputs.version }}"
49+
50+
- name: Docker Hub Description
51+
uses: peter-evans/dockerhub-description@v4
52+
with:
53+
username: ${{ secrets.DOCKERHUB_USERNAME }}
54+
password: ${{ secrets.DOCKERHUB_TOKEN }}
55+
repository: ${{ env.BASE_IMAGE }}
56+
readme-filepath: utils/docker/README.md
57+
short-description: "RoboCup Soccer Simulator Server"
58+
59+
app-image:
60+
runs-on: ubuntu-latest
61+
name: Build AppImage
62+
steps:
63+
- uses: actions/checkout@v4
64+
65+
- name: Create release folder
66+
run: |
67+
mkdir -p ${{ github.workspace }}/artifact
68+
69+
# ------------------------------------------- Ubuntu 20.04 AppImage
70+
- name: Prepare builder image for 20.04
71+
run: |
72+
docker build -t builder-image:2004 -f ./utils/appimage/Dockerfile.builder-2004 .
73+
74+
- name: Build app image on 20.04
75+
run: |
76+
docker run --privileged --name builder-2004 \
77+
builder-image:2004 /rcssserver/utils/appimage/build_appimage.sh
78+
docker cp builder-2004:/rcssserver-x86_64.AppImage ${{ github.workspace }}/artifact/rcssserver-x86_64-2004.AppImage
79+
80+
# ------------------------------------------- Artifact
81+
- name: Upload Artifact
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: rcssserver-x86_64
85+
path: ${{ github.workspace }}/artifact/*
86+
retention-days: 5
87+
88+
# ------------------------------------------- Release
89+
- uses: ncipollo/release-action@v1
90+
if: startsWith(github.ref, 'refs/tags/')
91+
with:
92+
artifacts: "${{ github.workspace }}/artifact/*"
93+
token: ${{ secrets.GITHUB_TOKEN }}
94+
# tag text is like "v1.2.3" so we need to remove the "v" from the tag
95+
tag: "${{ github.ref_name }}"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM ubuntu:18.04
2+
3+
COPY . /rcssserver
4+
5+
RUN apt-get clean && apt-get update --allow-insecure-repositories && \
6+
DEBIAN_FRONTEND="noninteractive" apt-get -y install \
7+
tzdata \
8+
gcc \
9+
g++ \
10+
wget \
11+
libfl-dev \
12+
flex \
13+
bison \
14+
libboost-all-dev \
15+
automake \
16+
make \
17+
cmake \
18+
iputils-ping \
19+
build-essential \
20+
libtool \
21+
fuse \
22+
libfuse-dev \
23+
zlib1g-dev
24+
25+
RUN cd /rcssserver && \
26+
find . -type f -name "*.cpp" -exec sed -i 's/#include <filesystem>/#include <experimental\/filesystem>/g' {} \; && \
27+
find . -type f -name "*.h" -exec sed -i 's/#include <filesystem>/#include <experimental\/filesystem>/g' {} \; && \
28+
find . -type f -name "*.hpp" -exec sed -i 's/#include <filesystem>/#include <experimental\/filesystem>/g' {} \; && \
29+
find . -type f -name "*.cpp" -exec sed -i 's/std::filesystem/std::experimental::filesystem/g' {} \; && \
30+
find . -type f -name "*.h" -exec sed -i 's/std::filesystem/std::experimental::filesystem/g' {} \; && \
31+
find . -type f -name "*.hpp" -exec sed -i 's/std::filesystem/std::experimental::filesystem/g' {} \; && \
32+
mkdir build && \
33+
cd build && \
34+
cmake .. && \
35+
make && \
36+
cd ..
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM ubuntu:20.04
2+
3+
COPY . /rcssserver
4+
5+
RUN apt-get clean && apt-get update --allow-insecure-repositories && \
6+
DEBIAN_FRONTEND="noninteractive" apt-get -y install \
7+
tzdata \
8+
gcc \
9+
g++ \
10+
wget \
11+
libfl-dev \
12+
flex \
13+
bison \
14+
libboost-all-dev \
15+
automake \
16+
make \
17+
cmake \
18+
iputils-ping \
19+
build-essential \
20+
libtool \
21+
fuse \
22+
libfuse-dev \
23+
zlib1g-dev
24+
25+
RUN cd /rcssserver && \
26+
mkdir build && \
27+
cd build && \
28+
cmake .. && \
29+
make && \
30+
cd ..
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM ubuntu:24.04
2+
3+
COPY . /rcssserver
4+
5+
RUN apt-get clean && apt-get update --allow-insecure-repositories && \
6+
DEBIAN_FRONTEND="noninteractive" apt-get -y install \
7+
tzdata \
8+
gcc \
9+
g++ \
10+
wget \
11+
libfl-dev \
12+
flex \
13+
bison \
14+
libboost-all-dev \
15+
automake \
16+
make \
17+
cmake \
18+
iputils-ping \
19+
build-essential \
20+
libtool \
21+
fuse \
22+
libfuse-dev
23+
24+
RUN cd /rcssserver && ./utils/appimage/build_code.sh

utils/appimage/build_appimage.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
set -e
3+
4+
wget -c "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" -O linuxdeploy-x86_64.AppImage
5+
chmod +x linuxdeploy-x86_64.AppImage
6+
mkdir rcssserver-x86_64
7+
8+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
9+
BUILD_PWD="${SCRIPT_DIR}/../../build"
10+
APP_IMAGE_DIR="${SCRIPT_DIR}"
11+
12+
13+
# find libc and libstdc++ libz dependencies
14+
LIBSTDCPP_PATH=$(ldd $BUILD_PWD/rcssserver | grep libstdc++ | awk '{ print $3 }')
15+
LIBZ_PATH=$(ldd $BUILD_PWD/rcssserver | grep libz.so | awk '{ print $3 }')
16+
LIBRCSSCLANGPARSER_PATH=$(ldd $BUILD_PWD/rcssserver | grep librcssclangparser.so | awk '{ print $3 }')
17+
LIBRCSSCONFPARSER_PATH=$(ldd $BUILD_PWD/rcssserver | grep librcssconfparser.so | awk '{ print $3 }')
18+
LIBRCSSGZ_PATH=$(ldd $BUILD_PWD/rcssserver | grep librcssgz.so | awk '{ print $3 }')
19+
LIBRCSSNET_PATH=$(ldd $BUILD_PWD/rcssserver | grep librcssnet.so | awk '{ print $3 }')
20+
21+
echo "LIBSTDCPP_PATH=" $LIBSTDCPP_PATH
22+
echo "LIBZ_PATH=" $LIBZ_PATH
23+
echo "LIBRCSSCLANGPARSER_PATH=" $LIBRCSSCLANGPARSER_PATH
24+
echo "LIBRCSSCONFPARSER_PATH=" $LIBRCSSCONFPARSER_PATH
25+
echo "LIBRCSSGZ_PATH=" $LIBRCSSGZ_PATH
26+
echo "LIBRCSSNET_PATH=" $LIBRCSSNET_PATH
27+
28+
./linuxdeploy-x86_64.AppImage --appdir ./rcssserver-x86_64 \
29+
-e $BUILD_PWD/rcssserver \
30+
-l $LIBRCSSCLANGPARSER_PATH \
31+
-l $LIBRCSSCONFPARSER_PATH \
32+
-l $LIBRCSSGZ_PATH \
33+
-l $LIBRCSSNET_PATH \
34+
-l $LIBSTDCPP_PATH \
35+
-l $LIBZ_PATH \
36+
-d $APP_IMAGE_DIR/rcssserver.desktop \
37+
-i $APP_IMAGE_DIR/rcssserver.png \
38+
--output appimage
39+
echo "App Image Created."

utils/appimage/build_code.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -e
3+
4+
mkdir build
5+
cd build
6+
cmake -DCMAKE_CXX_STANDARD=17 ..
7+
make
8+
cd ..

utils/appimage/rcssserver.desktop

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Desktop Entry]
2+
Version=1.0
3+
Type=Application
4+
Name=rcssserver
5+
Comment=Robocup 2D Soccer Simulation Server
6+
TryExec=rcssserver
7+
Exec=rcssserver
8+
Icon=rcssserver
9+
MimeType=image/x-foo;
10+
Categories=Development;
11+
X-KDE-Library=librcssserver
12+
X-KDE-FactoryName=rcssserverfactory
13+
X-KDE-ServiceType=RcssserverService
14+

utils/appimage/rcssserver.png

24.7 KB
Loading

utils/docker/Dockerfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#------------------------------------------------------
2+
# build stage
3+
#------------------------------------------------------
4+
5+
FROM ubuntu:24.04 AS BUILD
6+
7+
WORKDIR /rcssserver
8+
9+
# set environment variables
10+
ENV config_file=server.conf \
11+
DATE_FORMAT="%Y%m%d%H%M%S" \
12+
VERSION=18.1.3
13+
14+
15+
# install dependencies
16+
RUN apt-get clean && apt-get update --allow-insecure-repositories && \
17+
DEBIAN_FRONTEND="noninteractive" apt-get -y install \
18+
tzdata \
19+
sudo \
20+
gcc \
21+
g++ \
22+
wget \
23+
flex \
24+
bison \
25+
libboost-all-dev \
26+
automake \
27+
make \
28+
cmake \
29+
iputils-ping
30+
31+
# copy rcssserver source code
32+
COPY . /rcssserver
33+
34+
# make and install rcssserver
35+
RUN cd /rcssserver/ \
36+
&& ./bootstrap \
37+
&& ./configure --prefix=`pwd`/server-bin \
38+
&& make \
39+
&& make install \
40+
&& ldconfig
41+
42+
43+
44+
45+
#------------------------------------------------------
46+
# run stage
47+
#------------------------------------------------------
48+
FROM ubuntu:24.04 AS RUN
49+
50+
ENV LD_LIBRARY_PATH=/app/server-bin/lib:/usr/local/lib:/usr/lib:/lib \
51+
PATH=/app/server-bin/bin:$PATH
52+
53+
WORKDIR /app
54+
55+
COPY --from=BUILD /rcssserver/server-bin /app/server-bin
56+
57+
COPY utils/docker/docker-entrypoint.sh /app/docker-entrypoint.sh
58+
59+
CMD [ "bash", "/app/docker-entrypoint.sh" ]

utils/docker/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# RoboCup Soccer Simulator Server
2+
This image contains the RoboCup Soccer Simulator Server (rcssserver) installed and ready to use.
3+
4+
## Tags
5+
- latest
6+
7+
## How to use this image
8+
9+
Run the following command to start the server:
10+
```bash
11+
docker run --name rcssserver --network host -it rcssserver:latest
12+
```
13+
Now you can connect to the server using the monitor or a client.
14+
15+
## How to use custom configuration files
16+
1. You can mount a volume with your custom configuration files, like:
17+
```bash
18+
docker run --name rcssserver --network host -v /path/to/your/configs:/root/.rcssserver -it rcssserver:latest
19+
```
20+
2. You can add your custom configuration as environment variables, like:
21+
```bash
22+
docker run --name rcssserver --network host -e 'synch_mode=true' -it rcssserver:latest
23+
```
24+
3. You can run server with custom command line arguments, like:
25+
```bash
26+
docker run --name rcssserver --network host -it rcssserver:latest rcssserver server::synch_mode=true
27+
28+
```
29+
30+
31+
**Note**: You can either use one of the above methods at a time.
32+
It means:
33+
* if there is a server configuration file environment variable will be ignored.
34+
* if you use third method, the second method will be ignored.
35+
36+
37+
38+
## :incoming_envelope: Contributing
39+
40+
For bug reports, feature requests and latest updates, please goto
41+
https://github.com/rcsoccersim/rcssserver and open an issue or a pull request.
42+
43+
> The RoboCup Soccer Server Maintainance Group

0 commit comments

Comments
 (0)