done and dusted

This commit is contained in:
Loup-Garou911XD 2024-05-18 20:17:11 +05:30
parent 21fde5591d
commit d36a8edd07
7 changed files with 54 additions and 41 deletions

View File

@ -1 +1,3 @@
Dockerfile
.venv/
tools/pcommand
build/cmake/

View File

@ -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)

View File

@ -64,3 +64,4 @@
### Loup Garou
- Added sphinx documentation generation
- Added docker build

View File

@ -1,9 +0,0 @@
#!/bin/bash
pwd
echo
ls
echo
rm tools/pcommand
rm -rf .venv
make env
make cmake-server-build

View File

@ -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

View File

@ -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(),
version_num,
build_num,
)
os.remove("Dockerfile")

View File

@ -667,8 +667,6 @@ def prefab_binary_path() -> None:
)
def build_docker() -> None:
pass
import subprocess
import batools.build
batools.build.docker_build()