From acb42d1ff4e7b43022b7ab7f0631b12f27cf1dcd Mon Sep 17 00:00:00 2001 From: Loup-Garou911XD Date: Fri, 17 May 2024 03:08:06 +0530 Subject: [PATCH 01/12] docker in ballistica :o --- Makefile | 4 ++++ src/assets/docker/Dockerfile | 32 ++++++++++++++++++++++++++++++++ tools/batools/build.py | 17 +++++++++++++++++ tools/batools/pcommandmain.py | 1 + tools/batools/pcommands.py | 6 ++++++ 5 files changed, 60 insertions(+) create mode 100644 src/assets/docker/Dockerfile diff --git a/Makefile b/Makefile index 4efaf825..1e072576 100644 --- a/Makefile +++ b/Makefile @@ -222,6 +222,10 @@ pcommandbatch_speed_test: env # Prebuilt binaries for various platforms. +docker-linux-x86-64-server-release-build: + $(PCOMMAND) build_docker + + # WSL is Linux but running under Windows, so it can target either. By default # we want these top level targets (prefab-gui-debug, etc.) to yield native # Windows builds from WSL, but this env var can be set to override that. diff --git a/src/assets/docker/Dockerfile b/src/assets/docker/Dockerfile new file mode 100644 index 00000000..63723690 --- /dev/null +++ b/src/assets/docker/Dockerfile @@ -0,0 +1,32 @@ +FROM ubuntu:24.04 + +ENV LANG en_US.utf8 +ENV LANGUAGE=en_US +ARG BOMBSQUAD_VERSION=N/A + +ARG SOURCE_DIR=. + +RUN DEBIAN_FRONTEND=noninteractive \ + apt-get update -y && \ + apt-get install -y \ + python3.12-dev \ + libsdl2-dev \ + libvorbisfile3 \ + freeglut3-dev \ + libopenal-dev + +# Clean up +RUN apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* + +WORKDIR ${SOURCE_DIR} + +COPY ${SOURCE_DIR} ./ + +LABEL bombsquad_version=$BOMBSQUAD_VERSION + +CMD [ "./ballisticakit_server" ] + +# this does not port forward locally +# its just a hint for user which port to forward +EXPOSE 43210/udp diff --git a/tools/batools/build.py b/tools/batools/build.py index bb0bf65c..a8e6a70d 100644 --- a/tools/batools/build.py +++ b/tools/batools/build.py @@ -644,3 +644,20 @@ def cmake_prep_dir(dirname: str, verbose: bool = False) -> None: else: if verbose: print(f'{Clr.BLD}{title}:{Clr.RST} Keeping existing build dir.') + +def _docker_build(image_name, + dockerfile_dir, + bombsquad_version, + source_dir) -> None: + + build_cmd = ['docker','image','build', + '-t',image_name, + dockerfile_dir, + '--build-arg', f'BOMBSQUAD_VERSION={bombsquad_version}', + '--build-arg', f'SOURCE_DIR={source_dir}'] + + subprocess.run(build_cmd,check=True) + +# add option to toggle between prefab and cmake +def docker_build() -> None: + _docker_build('bsquad','src/assets/docker/','1.7.69','build/prefab/full/linux_x86_64_server/release') \ No newline at end of file diff --git a/tools/batools/pcommandmain.py b/tools/batools/pcommandmain.py index b0790e27..581af8d8 100644 --- a/tools/batools/pcommandmain.py +++ b/tools/batools/pcommandmain.py @@ -104,6 +104,7 @@ from batools.pcommands import ( ensure_prefab_platform, prefab_run_var, prefab_binary_path, + build_docker, make_prefab, lazybuild, efro_gradle, diff --git a/tools/batools/pcommands.py b/tools/batools/pcommands.py index 6bc07aac..cad1fa63 100644 --- a/tools/batools/pcommands.py +++ b/tools/batools/pcommands.py @@ -666,6 +666,12 @@ def prefab_binary_path() -> None: end='', ) +def build_docker() -> None: + pass + import subprocess + import batools.build + batools.build.docker_build() + def make_prefab() -> None: """Run prefab builds for the current platform.""" From 4382c396e55ac94a692d5018ef3de0cb6083377d Mon Sep 17 00:00:00 2001 From: Loup-Garou911XD Date: Fri, 17 May 2024 05:53:50 +0530 Subject: [PATCH 02/12] work in progress on docker build --- src/assets/docker/Dockerfile => Dockerfile | 30 ++++++++++++++-------- Makefile | 4 ++- do_stuff | 7 +++++ tools/batools/build.py | 18 +++++++++---- 4 files changed, 42 insertions(+), 17 deletions(-) rename src/assets/docker/Dockerfile => Dockerfile (55%) create mode 100755 do_stuff diff --git a/src/assets/docker/Dockerfile b/Dockerfile similarity index 55% rename from src/assets/docker/Dockerfile rename to Dockerfile index 63723690..110f5496 100644 --- a/src/assets/docker/Dockerfile +++ b/Dockerfile @@ -1,32 +1,40 @@ FROM ubuntu:24.04 ENV LANG en_US.utf8 -ENV LANGUAGE=en_US -ARG BOMBSQUAD_VERSION=N/A -ARG SOURCE_DIR=. +ENV LANGUAGE=en_US RUN DEBIAN_FRONTEND=noninteractive \ apt-get update -y && \ apt-get install -y \ python3.12-dev \ + python3.12-venv \ libsdl2-dev \ libvorbisfile3 \ freeglut3-dev \ - libopenal-dev + libopenal-dev \ + make -# Clean up -RUN apt-get clean && \ - rm -rf /var/lib/apt/lists/* /tmp/* +ARG BOMBSQUAD_VERSION=N/A -WORKDIR ${SOURCE_DIR} +# WORKDIR /home/ubuntu/ -COPY ${SOURCE_DIR} ./ +COPY ./ ./ballistica -LABEL bombsquad_version=$BOMBSQUAD_VERSION +WORKDIR /ballistica -CMD [ "./ballisticakit_server" ] +LABEL bombsquad_version=${BOMBSQUAD_VERSION} + +CMD [ "./do_stuff" ] + +# ENTRYPOINT ["./do_stuff"] + +# CMD [ "make" ] # this does not port forward locally # its just a hint for user which port to forward EXPOSE 43210/udp + +# Clean up +# RUN apt-get clean && \ +# rm -rf /var/lib/apt/lists/* /tmp/* \ No newline at end of file diff --git a/Makefile b/Makefile index 1e072576..8ed1adf9 100644 --- a/Makefile +++ b/Makefile @@ -222,9 +222,11 @@ pcommandbatch_speed_test: env # Prebuilt binaries for various platforms. -docker-linux-x86-64-server-release-build: +docker-build: $(PCOMMAND) build_docker +docker-run: + docker run -i bsquad # WSL is Linux but running under Windows, so it can target either. By default # we want these top level targets (prefab-gui-debug, etc.) to yield native diff --git a/do_stuff b/do_stuff new file mode 100755 index 00000000..ffe0c130 --- /dev/null +++ b/do_stuff @@ -0,0 +1,7 @@ +#!/bin/bash +pwd +echo +ls +echo +rm tools/pcommand +make env diff --git a/tools/batools/build.py b/tools/batools/build.py index a8e6a70d..a17d273a 100644 --- a/tools/batools/build.py +++ b/tools/batools/build.py @@ -647,17 +647,25 @@ def cmake_prep_dir(dirname: str, verbose: bool = False) -> None: def _docker_build(image_name, dockerfile_dir, - bombsquad_version, - source_dir) -> None: + bombsquad_version = None, + project_root = None) -> None: build_cmd = ['docker','image','build', '-t',image_name, dockerfile_dir, - '--build-arg', f'BOMBSQUAD_VERSION={bombsquad_version}', - '--build-arg', f'SOURCE_DIR={source_dir}'] + ] + if bombsquad_version is not None: + build_cmd = build_cmd+['--build-arg', f'BOMBSQUAD_VERSION={bombsquad_version}'] + # if project_root is not None: + # print(project_root) + # build_cmd = build_cmd+['--build-arg', f'PROJ_ROOT={project_root}'] subprocess.run(build_cmd,check=True) # add option to toggle between prefab and cmake def docker_build() -> None: - _docker_build('bsquad','src/assets/docker/','1.7.69','build/prefab/full/linux_x86_64_server/release') \ No newline at end of file + _docker_build('bsquad', + '.', + '1.7.69', + os.getcwd(), + ) \ No newline at end of file From a5baa6ff29bcd9ce92e949da0b9ae2b588f9930f Mon Sep 17 00:00:00 2001 From: Loup-Garou911XD Date: Fri, 17 May 2024 06:15:28 +0530 Subject: [PATCH 03/12] more work on docker build --- Dockerfile | 3 +++ do_stuff | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 110f5496..93067ea6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,12 +9,15 @@ RUN DEBIAN_FRONTEND=noninteractive \ apt-get install -y \ python3.12-dev \ python3.12-venv \ + python3-pip \ libsdl2-dev \ libvorbisfile3 \ freeglut3-dev \ libopenal-dev \ make +RUN apt-get install -y curl rsync +RUN apt-get install -y clang-format ARG BOMBSQUAD_VERSION=N/A # WORKDIR /home/ubuntu/ diff --git a/do_stuff b/do_stuff index ffe0c130..15af9f73 100755 --- a/do_stuff +++ b/do_stuff @@ -4,4 +4,6 @@ echo ls echo rm tools/pcommand +rm -rf .venv make env +make cmake \ No newline at end of file From 6acaa1065e571eea6e464585178ffa66fccc3c3d Mon Sep 17 00:00:00 2001 From: Loup-Garou911XD Date: Fri, 17 May 2024 06:44:24 +0530 Subject: [PATCH 04/12] finally its working --- Dockerfile | 19 ++++++++++--------- do_stuff | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 93067ea6..caefe9de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,10 @@ ENV LANG en_US.utf8 ENV LANGUAGE=en_US +COPY ./ ./ballistica + +WORKDIR /ballistica + RUN DEBIAN_FRONTEND=noninteractive \ apt-get update -y && \ apt-get install -y \ @@ -14,18 +18,15 @@ RUN DEBIAN_FRONTEND=noninteractive \ libvorbisfile3 \ freeglut3-dev \ libopenal-dev \ - make + make \ + curl \ + rsync \ + clang-format \ + cmake \ + libvorbis-dev -RUN apt-get install -y curl rsync -RUN apt-get install -y clang-format ARG BOMBSQUAD_VERSION=N/A -# WORKDIR /home/ubuntu/ - -COPY ./ ./ballistica - -WORKDIR /ballistica - LABEL bombsquad_version=${BOMBSQUAD_VERSION} CMD [ "./do_stuff" ] diff --git a/do_stuff b/do_stuff index 15af9f73..f47e0f5a 100755 --- a/do_stuff +++ b/do_stuff @@ -6,4 +6,4 @@ echo rm tools/pcommand rm -rf .venv make env -make cmake \ No newline at end of file +make cmake-server \ No newline at end of file From 0c54e7a99d10facef2b145656ee687465bd5223f Mon Sep 17 00:00:00 2001 From: Loup-Garou911XD Date: Fri, 17 May 2024 07:25:37 +0530 Subject: [PATCH 05/12] more stuff --- Dockerfile | 4 ++-- Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index caefe9de..e750de09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,9 +4,9 @@ ENV LANG en_US.utf8 ENV LANGUAGE=en_US -COPY ./ ./ballistica +COPY ./ /home/ubuntu/ballistica -WORKDIR /ballistica +WORKDIR /home/ubuntu/ballistica RUN DEBIAN_FRONTEND=noninteractive \ apt-get update -y && \ diff --git a/Makefile b/Makefile index 8ed1adf9..ae3d0026 100644 --- a/Makefile +++ b/Makefile @@ -226,7 +226,7 @@ docker-build: $(PCOMMAND) build_docker docker-run: - docker run -i bsquad + docker run -P -it bsquad # WSL is Linux but running under Windows, so it can target either. By default # we want these top level targets (prefab-gui-debug, etc.) to yield native From a89b94f090ec970785206d185f634fd63bcd0847 Mon Sep 17 00:00:00 2001 From: Loup-Garou911XD Date: Fri, 17 May 2024 08:03:14 +0530 Subject: [PATCH 06/12] i promise this is very cool --- Dockerfile | 60 ++++++++++++++++++++++++++++++++++++++---------------- do_stuff | 2 +- 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index e750de09..8aaba97b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,10 @@ -FROM ubuntu:24.04 +# Start with the base image +FROM ubuntu:24.04 AS builder ENV LANG en_US.utf8 - ENV LANGUAGE=en_US -COPY ./ /home/ubuntu/ballistica - -WORKDIR /home/ubuntu/ballistica - +# Install build dependencies RUN DEBIAN_FRONTEND=noninteractive \ apt-get update -y && \ apt-get install -y \ @@ -25,20 +22,47 @@ RUN DEBIAN_FRONTEND=noninteractive \ cmake \ libvorbis-dev -ARG BOMBSQUAD_VERSION=N/A +# Copy source code +COPY ./ /home/ubuntu/ballistica +WORKDIR /home/ubuntu/ballistica + +# Compile the application +RUN ./do_stuff + +# Optionally, clean up the build dependencies and any temporary files to reduce image size +# This step depends on how './do_stuff compile' works and if it generates any temporary files +RUN apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* + +# Create a new stage for the runtime environment +FROM ubuntu:24.04 + +ENV LANG en_US.utf8 +ENV LANGUAGE=en_US + +WORKDIR /home/ubuntu/ballistica + +# Install runtime dependencies +RUN DEBIAN_FRONTEND=noninteractive \ + apt-get update -y && \ + apt-get install -y \ + python3.12-venv \ + python3-pip \ + libsdl2-dev \ + libvorbisfile3 \ + freeglut3-dev \ + libopenal1 \ + curl + +# Copy the compiled application from the builder stage +COPY --from=builder /home/ubuntu/ballistica/build/cmake/server-debug/staged/ /home/ubuntu/ballistica + +ARG BOMBSQUAD_VERSION=N/A LABEL bombsquad_version=${BOMBSQUAD_VERSION} -CMD [ "./do_stuff" ] - -# ENTRYPOINT ["./do_stuff"] - -# CMD [ "make" ] - -# this does not port forward locally -# its just a hint for user which port to forward +# Expose the necessary port EXPOSE 43210/udp -# Clean up -# RUN apt-get clean && \ -# rm -rf /var/lib/apt/lists/* /tmp/* \ No newline at end of file +# Set the default command to run the application +CMD [ "./ballisticakit_server" ] diff --git a/do_stuff b/do_stuff index f47e0f5a..1b56c414 100755 --- a/do_stuff +++ b/do_stuff @@ -6,4 +6,4 @@ echo rm tools/pcommand rm -rf .venv make env -make cmake-server \ No newline at end of file +make cmake-server-build \ No newline at end of file From 7cb9cc93916dfad23a709bd6db78361a75807d25 Mon Sep 17 00:00:00 2001 From: Loup-Garou911XD Date: Fri, 17 May 2024 09:23:02 +0530 Subject: [PATCH 07/12] success!! --- .dockerignore | 1 + Dockerfile | 19 +++++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..1d1fe94d --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +Dockerfile \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8aaba97b..bd07f346 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,11 +30,6 @@ WORKDIR /home/ubuntu/ballistica # Compile the application RUN ./do_stuff -# Optionally, clean up the build dependencies and any temporary files to reduce image size -# This step depends on how './do_stuff compile' works and if it generates any temporary files -RUN apt-get clean && \ - rm -rf /var/lib/apt/lists/* /tmp/* - # Create a new stage for the runtime environment FROM ubuntu:24.04 @@ -43,10 +38,16 @@ ENV LANGUAGE=en_US WORKDIR /home/ubuntu/ballistica +ARG BOMBSQUAD_VERSION=N/A +LABEL bombsquad_version=${BOMBSQUAD_VERSION} + +# Copy apt cache from builder to avoid redownloading +COPY --from=builder /var/cache/apt/ /var/cache/apt/ +COPY --from=builder /var/lib/apt/lists/ /var/lib/apt/lists/ + # Install runtime dependencies RUN DEBIAN_FRONTEND=noninteractive \ - apt-get update -y && \ - apt-get install -y \ + apt-get install -y \ python3.12-venv \ python3-pip \ libsdl2-dev \ @@ -57,9 +58,7 @@ RUN DEBIAN_FRONTEND=noninteractive \ # Copy the compiled application from the builder stage COPY --from=builder /home/ubuntu/ballistica/build/cmake/server-debug/staged/ /home/ubuntu/ballistica - -ARG BOMBSQUAD_VERSION=N/A -LABEL bombsquad_version=${BOMBSQUAD_VERSION} +COPY --from=builder /home/ubuntu/ballistica/build/cmake/server-debug/ballisticakit_headless /home/ubuntu/ballistica/dist # Expose the necessary port EXPOSE 43210/udp From 21fde5591daa0f07ce8ca89807e3731f513695dc Mon Sep 17 00:00:00 2001 From: Loup-Garou911XD Date: Fri, 17 May 2024 18:29:17 +0530 Subject: [PATCH 08/12] work in progress --- Dockerfile | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index bd07f346..ca5d3d9f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,17 @@ +ARG cmake_build_type=Release +ARG base_image=ubuntu:24.04 + # Start with the base image -FROM ubuntu:24.04 AS builder +FROM ${base_image} AS builder ENV LANG en_US.utf8 ENV LANGUAGE=en_US +# Renew the arg +ARG cmake_build_type + +ENV CMAKE_BUILD_TYPE=${cmake_build_type} + # Install build dependencies RUN DEBIAN_FRONTEND=noninteractive \ apt-get update -y && \ @@ -28,25 +36,26 @@ COPY ./ /home/ubuntu/ballistica WORKDIR /home/ubuntu/ballistica # Compile the application -RUN ./do_stuff +RUN rm -rf .venv tools/pcommand +RUN make cmake-server-build # Create a new stage for the runtime environment -FROM ubuntu:24.04 +FROM ${base_image} + +# Renew the arg +ARG cmake_build_type ENV LANG en_US.utf8 ENV LANGUAGE=en_US WORKDIR /home/ubuntu/ballistica -ARG BOMBSQUAD_VERSION=N/A -LABEL bombsquad_version=${BOMBSQUAD_VERSION} - -# Copy apt cache from builder to avoid redownloading -COPY --from=builder /var/cache/apt/ /var/cache/apt/ -COPY --from=builder /var/lib/apt/lists/ /var/lib/apt/lists/ +ARG bombsquad_version=N/A +LABEL BOMBSQUAD_VERSION=${bombsquad_version} # Install runtime dependencies RUN DEBIAN_FRONTEND=noninteractive \ + apt-get update -y && \ apt-get install -y \ python3.12-venv \ python3-pip \ From d36a8edd07f68490cd4507249a8f5b60023b903b Mon Sep 17 00:00:00 2001 From: Loup-Garou911XD Date: Sat, 18 May 2024 20:17:11 +0530 Subject: [PATCH 09/12] done and dusted --- .dockerignore | 4 +- CHANGELOG.md | 1 + CONTRIBUTORS.md | 3 +- do_stuff | 9 ----- Dockerfile => src/assets/docker/Dockerfile | 44 ++++++++++++++-------- tools/batools/build.py | 32 +++++++++------- tools/batools/pcommands.py | 2 - 7 files changed, 54 insertions(+), 41 deletions(-) delete mode 100755 do_stuff rename Dockerfile => src/assets/docker/Dockerfile (59%) diff --git a/.dockerignore b/.dockerignore index 1d1fe94d..249ace41 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,3 @@ -Dockerfile \ No newline at end of file +.venv/ +tools/pcommand +build/cmake/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 03afd83a..4a113974 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ multiple `SockAddr`s; it will attempt to contact the host on all of them and use whichever responds first. This allows us to pass both ipv4 and ipv6 addresses when available and transparently use whichever is more performant. +- Added `docker-build` and `docker-run` targets to Makefile ### 1.7.34 (build 21823, api 8, 2024-04-26) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index dd21a689..30865a77 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -63,4 +63,5 @@ - Added support for joining using ipv6 address ### Loup Garou -- Added sphinx documentation generation \ No newline at end of file +- Added sphinx documentation generation +- Added docker build \ No newline at end of file diff --git a/do_stuff b/do_stuff deleted file mode 100755 index 1b56c414..00000000 --- a/do_stuff +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -pwd -echo -ls -echo -rm tools/pcommand -rm -rf .venv -make env -make cmake-server-build \ No newline at end of file diff --git a/Dockerfile b/src/assets/docker/Dockerfile similarity index 59% rename from Dockerfile rename to src/assets/docker/Dockerfile index ca5d3d9f..d2804a0d 100644 --- a/Dockerfile +++ b/src/assets/docker/Dockerfile @@ -1,20 +1,24 @@ +# if provided it will make debug build ARG cmake_build_type=Release + +# system to start with the build with +# currently will break for non ubuntu system ARG base_image=ubuntu:24.04 +#-------------------------------BUILDER-------------------------------- # Start with the base image FROM ${base_image} AS builder -ENV LANG en_US.utf8 -ENV LANGUAGE=en_US - # Renew the arg ARG cmake_build_type +ENV LANG en_US.utf8 +ENV LANGUAGE=en_US +ENV DEBIAN_FRONTEND=noninteractive ENV CMAKE_BUILD_TYPE=${cmake_build_type} # Install build dependencies -RUN DEBIAN_FRONTEND=noninteractive \ - apt-get update -y && \ +RUN apt-get update -y && \ apt-get install -y \ python3.12-dev \ python3.12-venv \ @@ -36,26 +40,30 @@ COPY ./ /home/ubuntu/ballistica WORKDIR /home/ubuntu/ballistica # Compile the application -RUN rm -rf .venv tools/pcommand RUN make cmake-server-build +RUN mkdir ./../ballistica_cmake_server +RUN mv build/cmake/* ./../ballistica_cmake_server +#-------------------------------RUNNER-------------------------------- # Create a new stage for the runtime environment FROM ${base_image} -# Renew the arg -ARG cmake_build_type - ENV LANG en_US.utf8 ENV LANGUAGE=en_US +ENV DEBIAN_FRONTEND=noninteractive -WORKDIR /home/ubuntu/ballistica +# Renew the arg +ARG cmake_build_type +LABEL BUILD_TYPE=${cmake_build_type} + +ARG bombsquad_build=N/A +LABEL BOMBSQUAD_BUILD=${bombsquad_build} ARG bombsquad_version=N/A LABEL BOMBSQUAD_VERSION=${bombsquad_version} # Install runtime dependencies -RUN DEBIAN_FRONTEND=noninteractive \ - apt-get update -y && \ +RUN apt-get update -y && \ apt-get install -y \ python3.12-venv \ python3-pip \ @@ -63,11 +71,17 @@ RUN DEBIAN_FRONTEND=noninteractive \ libvorbisfile3 \ freeglut3-dev \ libopenal1 \ - curl + curl \ + && rm -rf /var/lib/apt/lists/* # Copy the compiled application from the builder stage -COPY --from=builder /home/ubuntu/ballistica/build/cmake/server-debug/staged/ /home/ubuntu/ballistica -COPY --from=builder /home/ubuntu/ballistica/build/cmake/server-debug/ballisticakit_headless /home/ubuntu/ballistica/dist +COPY --from=builder /home/ubuntu/ballistica_cmake_server/*/staged \ + /home/ubuntu/ballistica +# ballisticakit_headless in staged is a symlink +COPY --from=builder /home/ubuntu/ballistica_cmake_server/*/ballisticakit_headless \ + /home/ubuntu/ballistica/dist + +WORKDIR /home/ubuntu/ballistica # Expose the necessary port EXPOSE 43210/udp diff --git a/tools/batools/build.py b/tools/batools/build.py index a17d273a..1cae58d3 100644 --- a/tools/batools/build.py +++ b/tools/batools/build.py @@ -645,27 +645,33 @@ def cmake_prep_dir(dirname: str, verbose: bool = False) -> None: if verbose: print(f'{Clr.BLD}{title}:{Clr.RST} Keeping existing build dir.') -def _docker_build(image_name, - dockerfile_dir, - bombsquad_version = None, - project_root = None) -> None: +def _docker_build(image_name : str, + dockerfile_dir : str, + bombsquad_version : str|None = None, + bombsquad_build : str|int|None = None, + cmake_build_type : str|None = None) -> None: build_cmd = ['docker','image','build', '-t',image_name, dockerfile_dir, ] if bombsquad_version is not None: - build_cmd = build_cmd+['--build-arg', f'BOMBSQUAD_VERSION={bombsquad_version}'] - # if project_root is not None: - # print(project_root) - # build_cmd = build_cmd+['--build-arg', f'PROJ_ROOT={project_root}'] - + build_cmd = build_cmd+['--build-arg', f'bombsquad_version={bombsquad_version}'] + if bombsquad_build is not None: + build_cmd = build_cmd+['--build-arg', f'bombsquad_build={str(bombsquad_build)}'] + if cmake_build_type is not None: + build_cmd = build_cmd+['--build-arg', f'cmake_build_type={cmake_build_type}'] subprocess.run(build_cmd,check=True) -# add option to toggle between prefab and cmake +# todo: add option to toggle between prefab and cmake def docker_build() -> None: + import shutil + shutil.copy("src/assets/docker/Dockerfile",".") + from batools import version + version_num,build_num =version.get_current_version() _docker_build('bsquad', '.', - '1.7.69', - os.getcwd(), - ) \ No newline at end of file + version_num, + build_num, + ) + os.remove("Dockerfile") \ No newline at end of file diff --git a/tools/batools/pcommands.py b/tools/batools/pcommands.py index cad1fa63..f33e1b86 100644 --- a/tools/batools/pcommands.py +++ b/tools/batools/pcommands.py @@ -667,8 +667,6 @@ def prefab_binary_path() -> None: ) def build_docker() -> None: - pass - import subprocess import batools.build batools.build.docker_build() From d67ae0c949aa3cd62501f118a2815ea5a6e5b10f Mon Sep 17 00:00:00 2001 From: Loup-Garou911XD Date: Sat, 18 May 2024 20:37:02 +0530 Subject: [PATCH 10/12] ci fix trial 1 --- Makefile | 2 +- config/spinoffconfig.py | 1 + tools/batools/build.py | 66 +++++++++++++++++++++++++------------- tools/batools/pcommands.py | 5 ++- 4 files changed, 49 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index ae3d0026..eec952de 100644 --- a/Makefile +++ b/Makefile @@ -226,7 +226,7 @@ docker-build: $(PCOMMAND) build_docker docker-run: - docker run -P -it bsquad + docker run -it bombsquad_server # WSL is Linux but running under Windows, so it can target either. By default # we want these top level targets (prefab-gui-debug, etc.) to yield native diff --git a/config/spinoffconfig.py b/config/spinoffconfig.py index 47d390eb..4da1e2ee 100644 --- a/config/spinoffconfig.py +++ b/config/spinoffconfig.py @@ -169,6 +169,7 @@ ctx.no_filter_dirs = { ctx.filter_file_names = { 'Makefile', '.gitignore', + '.dockerignore', '.gitattributes', 'README', 'README.md', diff --git a/tools/batools/build.py b/tools/batools/build.py index 1cae58d3..c13c3c12 100644 --- a/tools/batools/build.py +++ b/tools/batools/build.py @@ -645,33 +645,53 @@ def cmake_prep_dir(dirname: str, verbose: bool = False) -> None: if verbose: print(f'{Clr.BLD}{title}:{Clr.RST} Keeping existing build dir.') -def _docker_build(image_name : str, - dockerfile_dir : str, - bombsquad_version : str|None = None, - bombsquad_build : str|int|None = None, - cmake_build_type : str|None = None) -> None: - - build_cmd = ['docker','image','build', - '-t',image_name, - dockerfile_dir, - ] + +def _docker_build( + image_name: str, + dockerfile_dir: str, + bombsquad_version: str | None = None, + bombsquad_build: str | int | None = None, + cmake_build_type: str | None = None, +) -> None: + + build_cmd = [ + 'docker', + 'image', + 'build', + '-t', + image_name, + dockerfile_dir, + ] if bombsquad_version is not None: - build_cmd = build_cmd+['--build-arg', f'bombsquad_version={bombsquad_version}'] + build_cmd = build_cmd + [ + '--build-arg', + f'bombsquad_version={bombsquad_version}', + ] if bombsquad_build is not None: - build_cmd = build_cmd+['--build-arg', f'bombsquad_build={str(bombsquad_build)}'] + build_cmd = build_cmd + [ + '--build-arg', + f'bombsquad_build={str(bombsquad_build)}', + ] if cmake_build_type is not None: - build_cmd = build_cmd+['--build-arg', f'cmake_build_type={cmake_build_type}'] - subprocess.run(build_cmd,check=True) - + build_cmd = build_cmd + [ + '--build-arg', + f'cmake_build_type={cmake_build_type}', + ] + subprocess.run(build_cmd, check=True) + + # todo: add option to toggle between prefab and cmake def docker_build() -> None: import shutil - shutil.copy("src/assets/docker/Dockerfile",".") + + shutil.copy('src/assets/docker/Dockerfile', '.') from batools import version - version_num,build_num =version.get_current_version() - _docker_build('bsquad', - '.', - version_num, - build_num, - ) - os.remove("Dockerfile") \ No newline at end of file + + version_num, build_num = version.get_current_version() + _docker_build( + 'bombsquad_server', + '.', + version_num, + build_num, + ) + os.remove('Dockerfile') diff --git a/tools/batools/pcommands.py b/tools/batools/pcommands.py index f33e1b86..d5a08277 100644 --- a/tools/batools/pcommands.py +++ b/tools/batools/pcommands.py @@ -666,10 +666,13 @@ def prefab_binary_path() -> None: end='', ) + def build_docker() -> None: + """Build the docker image with bombsquad cmake server.""" import batools.build + batools.build.docker_build() - + def make_prefab() -> None: """Run prefab builds for the current platform.""" From 569ab27e850c14600ae46727ab7eac506ed5002c Mon Sep 17 00:00:00 2001 From: Loup-Garou911XD Date: Sat, 18 May 2024 20:42:15 +0530 Subject: [PATCH 11/12] ci fix trial 2 --- tools/batools/build.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/batools/build.py b/tools/batools/build.py index c13c3c12..3482f607 100644 --- a/tools/batools/build.py +++ b/tools/batools/build.py @@ -680,10 +680,11 @@ def _docker_build( subprocess.run(build_cmd, check=True) -# todo: add option to toggle between prefab and cmake def docker_build() -> None: + """Build docker image.""" import shutil + # todo: add option to toggle between prefab and cmake shutil.copy('src/assets/docker/Dockerfile', '.') from batools import version From 40096eaeb775b4039a21e3005378bcfd38c89e83 Mon Sep 17 00:00:00 2001 From: Loup-Garou911XD Date: Sun, 19 May 2024 01:48:03 +0530 Subject: [PATCH 12/12] moved Dockerfile to config/docker --- {src/assets => config}/docker/Dockerfile | 1 + tools/batools/build.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) rename {src/assets => config}/docker/Dockerfile (99%) diff --git a/src/assets/docker/Dockerfile b/config/docker/Dockerfile similarity index 99% rename from src/assets/docker/Dockerfile rename to config/docker/Dockerfile index d2804a0d..63dee431 100644 --- a/src/assets/docker/Dockerfile +++ b/config/docker/Dockerfile @@ -85,6 +85,7 @@ WORKDIR /home/ubuntu/ballistica # Expose the necessary port EXPOSE 43210/udp +EXPOSE 43210/tcp # Set the default command to run the application CMD [ "./ballisticakit_server" ] diff --git a/tools/batools/build.py b/tools/batools/build.py index 3482f607..876f3e8e 100644 --- a/tools/batools/build.py +++ b/tools/batools/build.py @@ -685,7 +685,7 @@ def docker_build() -> None: import shutil # todo: add option to toggle between prefab and cmake - shutil.copy('src/assets/docker/Dockerfile', '.') + shutil.copy('config/docker/Dockerfile', '.') from batools import version version_num, build_num = version.get_current_version()