Skip to content

Commit

Permalink
Merge pull request #699 from Loup-Garou911XD/master
Browse files Browse the repository at this point in the history
Docker build improvements
  • Loading branch information
efroemling authored May 19, 2024
2 parents 6fa12c8 + 4c54270 commit fb9c59c
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 26 deletions.
30 changes: 29 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -192,4 +202,22 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: sphinx_html_docs
path: build/sphinx
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
26 changes: 20 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

################################################################################
# #
Expand Down
20 changes: 7 additions & 13 deletions config/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 \
Expand All @@ -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" ]
16 changes: 10 additions & 6 deletions tools/batools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,9 @@ def _docker_build(
'build',
'-t',
image_name,
'-f',
dockerfile_dir,
'.',
]
if bombsquad_version is not None:
build_cmd = build_cmd + [
Expand All @@ -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')

0 comments on commit fb9c59c

Please sign in to comment.