diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index f27e3de9..7ddd733d 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -23,6 +23,7 @@ jobs: with: name: linux_x86_64_gui_(debug) path: build/prefab/full/linux_x86_64_gui + make_linux_x86_64_server_debug_build: runs-on: ubuntu-latest steps: @@ -40,6 +41,7 @@ jobs: with: name: linux_x86_64_server_(debug) path: build/prefab/full/linux_x86_64_server + make_linux_arm64_gui_debug_build: runs-on: ubuntu-latest steps: @@ -57,6 +59,7 @@ jobs: with: name: linux_arm64_gui_(debug) path: build/prefab/full/linux_arm64_gui + make_linux_arm64_server_debug_build: runs-on: ubuntu-latest steps: @@ -74,6 +77,7 @@ jobs: with: name: linux_arm64_server_(debug) path: build/prefab/full/linux_arm64_server + make_mac_x86_64_gui_debug_build: runs-on: ubuntu-latest steps: @@ -91,6 +95,7 @@ jobs: with: name: mac_x86_64_gui_(debug) path: build/prefab/full/mac_x86_64_gui + make_mac_x86_64_server_debug_build: runs-on: ubuntu-latest steps: @@ -108,6 +113,7 @@ jobs: with: name: mac_x86_64_server_(debug) path: build/prefab/full/mac_x86_64_server + make_mac_arm64_gui_debug_build: runs-on: ubuntu-latest steps: @@ -125,6 +131,7 @@ jobs: with: name: mac_arm64_gui_(debug) path: build/prefab/full/mac_arm64_gui + make_mac_arm64_server_debug_build: runs-on: ubuntu-latest steps: @@ -142,6 +149,7 @@ jobs: with: name: mac_arm64_server_(debug) path: build/prefab/full/mac_arm64_server + make_windows_x86_gui_debug_build: runs-on: ubuntu-latest steps: @@ -159,6 +167,7 @@ jobs: with: name: windows_x86_gui_(debug) path: build/prefab/full/windows_x86_gui + make_windows_x86_server_debug_build: runs-on: ubuntu-latest steps: @@ -176,6 +185,7 @@ jobs: with: name: windows_x86_server_(debug) path: build/prefab/full/windows_x86_server + make_sphinx_docs: runs-on: ubuntu-latest steps: @@ -192,4 +202,22 @@ jobs: uses: actions/upload-artifact@v4 with: name: sphinx_html_docs - path: build/sphinx \ No newline at end of file + path: build/sphinx + + make_docker_image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Setup project environment + run: make env + - name: Make the build + run: make docker-save + - name: Upload the build + uses: actions/upload-artifact@v4 + with: + name: docker_server(release) + path: build/docker/bombsquad_server_docker.tar \ No newline at end of file diff --git a/Makefile b/Makefile index eec952de..9b90f040 100644 --- a/Makefile +++ b/Makefile @@ -222,12 +222,6 @@ pcommandbatch_speed_test: env # Prebuilt binaries for various platforms. -docker-build: - $(PCOMMAND) build_docker - -docker-run: - 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 # Windows builds from WSL, but this env var can be set to override that. @@ -1182,6 +1176,26 @@ clion-staging: assets-cmake resources meta cmake-modular-server-build cmake-modular-server-binary \ cmake-modular-server-clean clion-staging +################################################################################ +# # +# Docker # +# # +################################################################################ + +docker-build: assets-cmake + $(PCOMMAND) build_docker + +docker-run: + docker run -it bombsquad_server + +docker-save: docker-build + mkdir -p build/docker/ + docker save bombsquad_server -o build/docker/bombsquad_server_docker.tar + +docker-clean: + rm build/docker/bombsquad_server_docker.tar + docker rmi bombsquad_server --force + docker system prune ################################################################################ # # diff --git a/config/docker/Dockerfile b/config/docker/Dockerfile index 63dee431..957ad891 100644 --- a/config/docker/Dockerfile +++ b/config/docker/Dockerfile @@ -40,9 +40,9 @@ COPY ./ /home/ubuntu/ballistica WORKDIR /home/ubuntu/ballistica # Compile the application -RUN make cmake-server-build -RUN mkdir ./../ballistica_cmake_server -RUN mv build/cmake/* ./../ballistica_cmake_server +RUN make cmake-server-build \ + && mkdir ./../ballistica_cmake_server \ + && mv build/cmake/* ./../ballistica_cmake_server #-------------------------------RUNNER-------------------------------- # Create a new stage for the runtime environment @@ -65,14 +65,9 @@ LABEL BOMBSQUAD_VERSION=${bombsquad_version} # Install runtime dependencies RUN apt-get update -y && \ apt-get install -y \ - python3.12-venv \ - python3-pip \ - libsdl2-dev \ - libvorbisfile3 \ - freeglut3-dev \ - libopenal1 \ - curl \ - && rm -rf /var/lib/apt/lists/* + python3.12-dev \ + && rm -rf /var/lib/apt/lists/* \ + && python3.12 -c "import uuid;print(uuid.uuid4())">/etc/machine-id # Copy the compiled application from the builder stage COPY --from=builder /home/ubuntu/ballistica_cmake_server/*/staged \ @@ -85,7 +80,6 @@ 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" ] +CMD [ "./ballisticakit_server" ] \ No newline at end of file diff --git a/tools/batools/build.py b/tools/batools/build.py index 876f3e8e..940d8d19 100644 --- a/tools/batools/build.py +++ b/tools/batools/build.py @@ -660,7 +660,9 @@ def _docker_build( 'build', '-t', image_name, + '-f', dockerfile_dir, + '.', ] if bombsquad_version is not None: build_cmd = build_cmd + [ @@ -682,17 +684,19 @@ def _docker_build( def docker_build() -> None: """Build docker image.""" - import shutil - # todo: add option to toggle between prefab and cmake - shutil.copy('config/docker/Dockerfile', '.') from batools import version version_num, build_num = version.get_current_version() + image_name = 'bombsquad_server' + + print( + f'Building docker image {image_name}' + + 'version {version_num}:{build_num}' + ) _docker_build( - 'bombsquad_server', - '.', + image_name, + 'config/docker/Dockerfile', version_num, build_num, ) - os.remove('Dockerfile')