-
Notifications
You must be signed in to change notification settings - Fork 211
build: Implement docker build #1774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| FROM debian:12.10-slim | ||
|
|
||
| # Build arguments | ||
| ARG CMAKE_VERSION="3.31.6" | ||
| ARG GIT_VERSION="2.49.0" | ||
| ARG UID | ||
| ARG GID | ||
|
|
||
| # Install utils | ||
| RUN apt update \ | ||
| && apt install wget gpg unzip git -y \ | ||
| && dpkg --add-architecture i386 \ | ||
| && apt clean \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Install wine | ||
| RUN mkdir -pm755 /etc/apt/keyrings \ | ||
| && (wget -O - https://dl.winehq.org/wine-builds/winehq.key | gpg --dearmor -o /etc/apt/keyrings/winehq-archive.key -) \ | ||
| && wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/debian/dists/bookworm/winehq-bookworm.sources \ | ||
| && apt update \ | ||
| && apt install --no-install-recommends winehq-stable -y \ | ||
| && apt clean \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
| # Setup build folder | ||
| RUN mkdir /build | ||
| RUN chown ${UID}:${GID} /build | ||
|
|
||
| USER ${UID}:${GID} | ||
| WORKDIR /build/tools | ||
|
|
||
| # Install cmake windows | ||
| RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-windows-x86_64.zip \ | ||
| && unzip cmake-${CMAKE_VERSION}-windows-x86_64.zip -d /build/tools/ \ | ||
| && mv /build/tools/cmake-${CMAKE_VERSION}-windows-x86_64 /build/tools/cmake \ | ||
| && find /build/tools/ -name "*.zip" -exec rm -f {} + | ||
|
|
||
| # Install git windows | ||
| RUN wget https://github.com/git-for-windows/git/releases/download/v${GIT_VERSION}.windows.1/MinGit-${GIT_VERSION}-64-bit.zip \ | ||
| && unzip MinGit-${GIT_VERSION}-64-bit.zip -d /build/tools/ \ | ||
| && mv /build/tools/cmd /build/tools/git \ | ||
| && find /build/tools/ -name "*.zip" -exec rm -f {} + | ||
|
|
||
| # Install Visual Studio 6 Portable | ||
| RUN wget https://github.com/itsmattkc/MSVC600/archive/refs/heads/master.zip \ | ||
| && unzip master.zip -d /build/tools \ | ||
| && mv /build/tools/MSVC600-master/ /build/tools/vs6 \ | ||
| && find /build/tools/ -name "*.zip" -exec rm -f {} + | ||
|
|
||
|
|
||
| #Install ninja | ||
| RUN wget https://github.com/ninja-build/ninja/releases/download/v1.13.1/ninja-win.zip \ | ||
| && unzip ninja-win.zip -d /build/tools/ \ | ||
| && find /build/tools/ -name "*.zip" -exec rm -f {} + | ||
|
|
||
| # Setup wine prefix | ||
| ENV WINEDEBUG=-all | ||
| ENV WINEARCH=win64 | ||
| ENV WINEPREFIX=/build/prefix64 | ||
|
|
||
| # Create empty TEMP folder for linking | ||
| RUN mkdir /build/tmp | ||
| ENV TMP="Z:\\build\\tmp" | ||
| ENV TEMP="Z:\\build\\tmp" | ||
| ENV TEMPDIR="Z:\\build\\tmp" | ||
|
|
||
| # Setup Visual Studio 6 Environment variables | ||
| ENV VS="Z:\\build\\tools\\vs6" | ||
| ENV MSVCDir="$VS\\vc98" | ||
| ENV WINEPATH="C:\\windows\\system32;\ | ||
| $VS\\vc98\\bin;\ | ||
| $VS\\vc98\\lib;\ | ||
| $VS\\vc98\\include;\ | ||
| $VS\\common\\Tools;\ | ||
| $VS\\common\\MSDev98\\bin" | ||
| ENV LIB="$VS\\vc98\\Lib;$VS\\vc98\\MFC\\Lib;Z:\\build\\cnc\\build\\vc6" | ||
| ENV INCLUDE="$VS\\vc98\\ATL\\INCLUDE;\ | ||
| $VS\\vc98\\INCLUDE;\ | ||
| $VS\\vc98\\MFC\\INCLUDE;\ | ||
| $VS\\vc98\\Include" | ||
| ENV CC="$VS\\vc98\\bin\\CL.exe" | ||
| ENV CXX="$VS\\vc98\\bin\\CL.exe" | ||
| ENV PRESET=vc6 | ||
|
|
||
| #prevent cache warning | ||
| ENV HOME=/build/tmp/home | ||
| RUN mkdir /build/tmp/home | ||
|
|
||
| WORKDIR /build/cnc | ||
|
|
||
| USER root | ||
| COPY entrypoint.sh /entrypoint.sh | ||
| RUN chmod +x /entrypoint.sh | ||
| CMD /entrypoint.sh |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
| cd /build/cnc | ||
| wineboot | ||
| if [ "${FORCE_CMAKE:-}" = "true" ] || [ ! -f build/docker/build.ninja ]; then | ||
| wine /build/tools/cmake/bin/cmake.exe \ | ||
| --preset ${PRESET} \ | ||
| -DCMAKE_SYSTEM="Windows" \ | ||
| -DCMAKE_SYSTEM_NAME="Windows" \ | ||
| -DCMAKE_SIZEOF_VOID_P=4 \ | ||
| -DCMAKE_MAKE_PROGRAM="Z:/build/tools/ninja.exe" \ | ||
| -DCMAKE_C_COMPILER="Z:/build/tools/vs6/vc98/bin/cl.exe" \ | ||
| -DCMAKE_CXX_COMPILER="Z:/build/tools/vs6/vc98/bin/cl.exe" \ | ||
| -DGIT_EXECUTABLE="Z:/build/tools/git/git.exe" \ | ||
| -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \ | ||
| -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ | ||
| -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ | ||
| -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \ | ||
| -DCMAKE_DISABLE_PRECOMPILE_HEADERS=1 \ | ||
| -DCMAKE_C_COMPILER_WORKS=1 \ | ||
| -DCMAKE_CXX_COMPILER_WORKS=1 \ | ||
| -B /build/cnc/build/docker | ||
| fi | ||
|
|
||
| cd /build/cnc/build/docker | ||
| wine cmd /c "set TMP=Z:\build\tmp& set TEMP=Z:\build\tmp& Z:\build\tools\ninja.exe $MAKE_TARGET" | ||
|
|
||
|
|
|
xezon marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| #!/bin/bash | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
| RESOURCES_DIR=$SCRIPT_DIR/../resources | ||
|
|
||
|
|
||
| usage() { | ||
| cat <<EOF | ||
| Usage: | ||
| $(basename "$0") [OPTIONS] [TARGET] | ||
|
|
||
| TARGET is passed to ninja.exe | ||
|
|
||
| Options: | ||
| -h, --help Show this help and exit | ||
| --cmake Force run cmake. | ||
| --bash Run the container interactively with bash entrypoint. | ||
|
|
||
| Examples: | ||
| $(basename "$0") | ||
| $(basename "$0") my_target | ||
| $(basename "$0") --cmake | ||
| $(basename "$0") --cmake my_target | ||
| $(basename "$0") --bash | ||
| EOF | ||
| } | ||
|
|
||
|
|
||
| FORCE_CMAKE="false" | ||
| MAKE_TARGET="" | ||
| INTERACTIVE="false" | ||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| -h|--help) | ||
| usage | ||
| exit 0 | ||
| ;; | ||
| --cmake) | ||
| FORCE_CMAKE="true" | ||
| shift | ||
| ;; | ||
| --bash) | ||
| INTERACTIVE="true" | ||
| shift | ||
| ;; | ||
| --) # end of options | ||
| shift | ||
| break | ||
| ;; | ||
| -*) | ||
| echo "Unknown option: $1" >&2 | ||
| usage | ||
| exit 1 | ||
| ;; | ||
| *) | ||
| # Positional TARGET (accept only one) | ||
| MAKE_TARGET="$MAKE_TARGET $1" | ||
| shift | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
|
|
||
| docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) $RESOURCES_DIR/dockerbuild -t zerohour-build | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This mentions "zerohour-build". Does this mean it only builds zero hour, never generals? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested and it builds both targets, I believe its just the name the built container is assigned? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can name it to clarify that both games are in there? |
||
| if [[ "$INTERACTIVE" == "true" ]]; then | ||
| FLAGS=" -it --entrypoint bash" | ||
| else | ||
| FLAGS="" | ||
| fi | ||
| docker run -u $(id -u):$(id -g) -e MAKE_TARGET="$MAKE_TARGET" -e FORCE_CMAKE=$FORCE_CMAKE -v "`pwd`":/build/cnc --rm $FLAGS zerohour-build | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.