Skip to content

Commit

Permalink
Merge pull request #711 from Loup-Garou911XD/master
Browse files Browse the repository at this point in the history
improvements to docker builds
  • Loading branch information
efroemling authored Jun 17, 2024
2 parents ce26be2 + 9dac952 commit 6660b90
Show file tree
Hide file tree
Showing 11 changed files with 469 additions and 110 deletions.
30 changes: 26 additions & 4 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- cron: '30 5 * * *'

jobs:
make_docker_image:
make_docker_gui_debug_image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -16,13 +16,35 @@ jobs:
- name: Setup project environment
run: make env
- name: Make the build
run: make docker-save
run: |
make docker-gui-debug
make docker-save
- name: Upload the build
uses: actions/upload-artifact@v4
with:
name: docker_server(release)
path: build/docker/bombsquad_server_docker.tar
name: docker_gui(debug)
path: build/docker/bombsquad_gui_debug_docker.tar

make_docker_server_debug_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-server-debug
make docker-save
- name: Upload the build
uses: actions/upload-artifact@v4
with:
name: docker_server(debug)
path: build/docker/bombsquad_server_debug_docker.tar

make_sphinx_docs:
runs-on: ubuntu-latest
steps:
Expand Down
32 changes: 29 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ jobs:
allowUpdates: true
artifacts: windows_x86_server_debug.tar

release_docker_image:
release_docker_gui_image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -219,12 +219,38 @@ jobs:
- name: Setup project environment
run: make env
- name: Make the build
run: make docker-save
run: |
make docker-gui-release
make docker-save
- name: Rename the build
run: mv build/docker/bombsquad_gui_release_docker.tar build/docker/bombsquad_docker_gui.tar
- name: Upload the build
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: build/docker/bombsquad_server_docker.tar
artifacts: build/docker/bombsquad_docker_gui.tar

release_docker_server_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-server-release
make docker-save
- name: Rename the build
run: mv build/docker/bombsquad_server_release_docker.tar build/docker/bombsquad_docker_server.tar
- name: Upload the build
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: build/docker/bombsquad_docker_server.tar

release_sphinx_docs:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
two forms. Now it is possible to provide both.
- Spaz classes now have a `default_hitpoints` which makes customizing that
easier (Thanks rabbitboom!)
- Added `docker-build`, `docker-run`, `docker-clean` and `docker-save` targets
- Added `docker-gui-release`, `docker-gui-debug`, `docker-server-release`, `docker-server-debug`, `docker-clean` and `docker-save` targets
to Makefile.
- Fixed an issue in Assault where being teleported back to base with a sticky
bomb stuck to you would do some crazy rubber-band-launching thing (Thanks
Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@

### Loup Garou
- Added sphinx documentation generation
- Added docker build
- Added docker build system
- Various CI/CD improvements
36 changes: 26 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1183,23 +1183,39 @@ clion-staging: assets-cmake resources meta
# #
################################################################################

# Build the docker image named bombsquad_server
docker-build: assets-cmake
$(PCOMMAND) build_docker
# Build the gui release docker image
docker-gui-release: assets-cmake
$(PCOMMAND) build_docker_gui_release

# Run the bombsquad_server image
docker-run:
docker run -it bombsquad_server
# Build the gui debug docker image
docker-gui-debug: assets-cmake
$(PCOMMAND) build_docker_gui_debug

# Build the server release docker image
docker-server-release: assets-cmake
$(PCOMMAND) build_docker_server_release

# Build the server debug docker image
docker-server-debug: assets-cmake
$(PCOMMAND) build_docker_server_debug

# Build the gui release docker image for arm64
docker-arm64-gui-release: assets-cmake
$(PCOMMAND) build_docker_arm64_gui_release

# Build the server release docker image for arm64
docker-arm64-server-release: assets-cmake
$(PCOMMAND) build_docker_arm64_server_release

# Save the bombsquad_server docker image to build/docker/bombsquad_server_docker.tar
docker-save: docker-build
docker-save:
mkdir -p build/docker/
docker save bombsquad_server -o build/docker/bombsquad_server_docker.tar
$(PCOMMAND) save_docker_images

# Cleanup docker files
docker-clean:
rm build/docker/bombsquad_server_docker.tar
docker rmi bombsquad_server --force
rm -rf build/docker/
$(PCOMMAND) remove_docker_images
docker system prune


Expand Down
80 changes: 49 additions & 31 deletions config/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
# 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
# whether to make GUI or headless build (defaults to headless)
ARG headless_build=1
# system to start with the build with
# currently will break for other images
ARG base_image=ubuntu:latest

#-------------------------------BUILDER--------------------------------
# Start with the base image
FROM ${base_image} AS builder

# Renew the arg
# Renew the args
ARG headless_build
ARG cmake_build_type

ENV LANG en_US.utf8
# Environment settings
ENV LANG=en_US.utf8
ENV LANGUAGE=en_US
ENV LC_ALL=en_US.utf8
ENV DEBIAN_FRONTEND=noninteractive
ENV CMAKE_BUILD_TYPE=${cmake_build_type}
ENV HEADLESS_BUILD=${headless_build}

# Install build dependencies
RUN apt-get update -y && \
Expand All @@ -24,62 +29,75 @@ RUN apt-get update -y && \
python3.12-venv \
python3-pip \
libsdl2-dev \
libvorbisfile3 \
freeglut3-dev \
libglut-dev \
libopenal-dev \
libvorbis-dev \
make \
curl \
rsync \
clang-format \
cmake \
libvorbis-dev
cmake

# Copy source code
COPY ./ /home/ubuntu/ballistica
COPY ./ /ballistica

WORKDIR /home/ubuntu/ballistica
# Set the working directory
WORKDIR /ballistica

# Compile the application
RUN make cmake-server-build \
&& mkdir ./../ballistica_cmake_server \
&& mv build/cmake/* ./../ballistica_cmake_server
RUN mkdir /ballistica_cmake && \
if [ "$HEADLESS_BUILD" != "0" ]; then \
make cmake-server-build && \
mv build/cmake/*/ballisticakit_headless build/cmake/*/staged/dist; \
else \
make cmake-build && \
mv build/cmake/*/ballisticakit build/cmake/*/staged/; \
fi && \
mv build/cmake/*/staged/* /ballistica_cmake


#-------------------------------RUNNER--------------------------------
# Create a new stage for the runtime environment
FROM ${base_image}

# Environment settings
ENV LANG en_US.utf8
ENV LANGUAGE=en_US
ENV LC_ALL=en_US.utf8
ENV DEBIAN_FRONTEND=noninteractive

# Renew the arg
# Renew the args
ARG headless_build
ENV HEADLESS_BUILD=${headless_build}
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}
LABEL BOMBSQUAD_BUILD_TYPE=${cmake_build_type}

# Install runtime dependencies
RUN apt-get update -y && \
apt-get install -y \
python3.12-dev \
&& rm -rf /var/lib/apt/lists/* \
&& python3.12 -c "import uuid;print(uuid.uuid4())">/etc/machine-id
apt-get install -y \
python3.12-dev && \
if [ "$HEADLESS_BUILD" = "0" ]; then \
apt-get install -y \
libsdl2-dev \
libvorbis-dev \
libglut-dev \
libopenal-dev; \
fi && \
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 \
COPY --from=builder /ballistica_cmake \
/home/ubuntu/ballistica
# ballisticakit_headless in staged is a symlink
COPY --from=builder /home/ubuntu/ballistica_cmake_server/*/ballisticakit_headless \
/home/ubuntu/ballistica/dist

# Set the working directory
WORKDIR /home/ubuntu/ballistica

RUN ln -s ballisticakit* run

# Expose the necessary port
EXPOSE 43210/udp

# Set the default command to run the application
CMD [ "./ballisticakit_server" ]
CMD [ "./run" ]
Loading

0 comments on commit 6660b90

Please sign in to comment.