Skip to content

Commit

Permalink
Merge pull request #111 from startersclan/enhancement/add-bf2stats-2.…
Browse files Browse the repository at this point in the history
…8.1-variants

Enhancement: Add bf2stats 2.8.1 variants
  • Loading branch information
leojonathanoh authored Feb 23, 2024
2 parents e031f0a + 8f2635f commit 4da26d1
Show file tree
Hide file tree
Showing 21 changed files with 3,543 additions and 6 deletions.
134 changes: 134 additions & 0 deletions .github/workflows/ci-master-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,73 @@ jobs:
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

# This step generates the docker tags
- name: Prepare
id: prep-v1-5-3153-0-bf2all64-bf2stats-2-8-1
run: |
set -e
# Get ref, i.e. <branch_name> from refs/heads/<branch_name>, or <tag-name> from refs/tags/<tag_name>. E.g. 'master' or 'v0.0.0'
REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev )
# Get short commit hash E.g. 'abc0123'
SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 )
# Generate docker image tags
# E.g. 'v0.0.0-<variant>' and 'v0.0.0-abc0123-<variant>'
# E.g. 'master-<variant>' and 'master-abc0123-<variant>'
VARIANT="v1.5.3153.0-bf2all64-bf2stats-2.8.1"
REF_VARIANT="${REF}-${VARIANT}"
REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}"
# Pass variables to next step
echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_OUTPUT
echo "VARIANT=$VARIANT" >> $GITHUB_OUTPUT
echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_OUTPUT
echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_OUTPUT
- name: v1.5.3153.0-bf2all64-bf2stats-2.8.1 - Build (PRs)
# Run only on pull requests
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v3
with:
context: variants/v1.5.3153.0-bf2all64-bf2stats-2.8.1
platforms: linux/386,linux/amd64
push: false
tags: |
${{ github.repository }}:${{ steps.prep-v1-5-3153-0-bf2all64-bf2stats-2-8-1.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-v1-5-3153-0-bf2all64-bf2stats-2-8-1.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: v1.5.3153.0-bf2all64-bf2stats-2.8.1 - Build and push (master)
# Run only on master
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v3
with:
context: variants/v1.5.3153.0-bf2all64-bf2stats-2.8.1
platforms: linux/386,linux/amd64
push: true
tags: |
${{ github.repository }}:${{ steps.prep-v1-5-3153-0-bf2all64-bf2stats-2-8-1.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-v1-5-3153-0-bf2all64-bf2stats-2-8-1.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: v1.5.3153.0-bf2all64-bf2stats-2.8.1 - Build and push (release)
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v3
with:
context: variants/v1.5.3153.0-bf2all64-bf2stats-2.8.1
platforms: linux/386,linux/amd64
push: true
tags: |
${{ github.repository }}:${{ steps.prep-v1-5-3153-0-bf2all64-bf2stats-2-8-1.outputs.VARIANT }}
${{ github.repository }}:${{ steps.prep-v1-5-3153-0-bf2all64-bf2stats-2-8-1.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-v1-5-3153-0-bf2all64-bf2stats-2-8-1.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

# This step generates the docker tags
- name: Prepare
id: prep-v1-5-3153-0-bf2all64-bf2stats-3-1-0
Expand Down Expand Up @@ -1418,6 +1485,73 @@ jobs:
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

# This step generates the docker tags
- name: Prepare
id: prep-v1-5-3153-0-bf2stats-2-8-1
run: |
set -e
# Get ref, i.e. <branch_name> from refs/heads/<branch_name>, or <tag-name> from refs/tags/<tag_name>. E.g. 'master' or 'v0.0.0'
REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev )
# Get short commit hash E.g. 'abc0123'
SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 )
# Generate docker image tags
# E.g. 'v0.0.0-<variant>' and 'v0.0.0-abc0123-<variant>'
# E.g. 'master-<variant>' and 'master-abc0123-<variant>'
VARIANT="v1.5.3153.0-bf2stats-2.8.1"
REF_VARIANT="${REF}-${VARIANT}"
REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}"
# Pass variables to next step
echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_OUTPUT
echo "VARIANT=$VARIANT" >> $GITHUB_OUTPUT
echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_OUTPUT
echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_OUTPUT
- name: v1.5.3153.0-bf2stats-2.8.1 - Build (PRs)
# Run only on pull requests
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v3
with:
context: variants/v1.5.3153.0-bf2stats-2.8.1
platforms: linux/386,linux/amd64
push: false
tags: |
${{ github.repository }}:${{ steps.prep-v1-5-3153-0-bf2stats-2-8-1.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-v1-5-3153-0-bf2stats-2-8-1.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: v1.5.3153.0-bf2stats-2.8.1 - Build and push (master)
# Run only on master
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v3
with:
context: variants/v1.5.3153.0-bf2stats-2.8.1
platforms: linux/386,linux/amd64
push: true
tags: |
${{ github.repository }}:${{ steps.prep-v1-5-3153-0-bf2stats-2-8-1.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-v1-5-3153-0-bf2stats-2-8-1.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: v1.5.3153.0-bf2stats-2.8.1 - Build and push (release)
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v3
with:
context: variants/v1.5.3153.0-bf2stats-2.8.1
platforms: linux/386,linux/amd64
push: true
tags: |
${{ github.repository }}:${{ steps.prep-v1-5-3153-0-bf2stats-2-8-1.outputs.VARIANT }}
${{ github.repository }}:${{ steps.prep-v1-5-3153-0-bf2stats-2-8-1.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-v1-5-3153-0-bf2stats-2-8-1.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

# This step generates the docker tags
- name: Prepare
id: prep-v1-5-3153-0-bf2stats-3-1-0
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ All images contain [`Battlefield 2 Server 1.50`](https://www.bf-games.net/downlo
| `:v1.5.3153.0-bf2all64-bf2stats-2.5.1` | [View](variants/v1.5.3153.0-bf2all64-bf2stats-2.5.1 ) |
| `:v1.5.3153.0-bf2all64-bf2stats-2.6.0` | [View](variants/v1.5.3153.0-bf2all64-bf2stats-2.6.0 ) |
| `:v1.5.3153.0-bf2all64-bf2stats-2.7.2` | [View](variants/v1.5.3153.0-bf2all64-bf2stats-2.7.2 ) |
| `:v1.5.3153.0-bf2all64-bf2stats-2.8.1` | [View](variants/v1.5.3153.0-bf2all64-bf2stats-2.8.1 ) |
| `:v1.5.3153.0-bf2all64-bf2stats-3.1.0` | [View](variants/v1.5.3153.0-bf2all64-bf2stats-3.1.0 ) |
| `:v1.5.3153.0-bf2all64-bf2stats-3.1.2` | [View](variants/v1.5.3153.0-bf2all64-bf2stats-3.1.2 ) |
| `:v1.5.3153.0-bf2all64-bf2stats-3.2.0` | [View](variants/v1.5.3153.0-bf2all64-bf2stats-3.2.0 ) |
Expand All @@ -32,6 +33,7 @@ All images contain [`Battlefield 2 Server 1.50`](https://www.bf-games.net/downlo
| `:v1.5.3153.0-bf2stats-2.5.1` | [View](variants/v1.5.3153.0-bf2stats-2.5.1 ) |
| `:v1.5.3153.0-bf2stats-2.6.0` | [View](variants/v1.5.3153.0-bf2stats-2.6.0 ) |
| `:v1.5.3153.0-bf2stats-2.7.2` | [View](variants/v1.5.3153.0-bf2stats-2.7.2 ) |
| `:v1.5.3153.0-bf2stats-2.8.1` | [View](variants/v1.5.3153.0-bf2stats-2.8.1 ) |
| `:v1.5.3153.0-bf2stats-3.1.0` | [View](variants/v1.5.3153.0-bf2stats-3.1.0 ) |
| `:v1.5.3153.0-bf2stats-3.1.2` | [View](variants/v1.5.3153.0-bf2stats-3.1.2 ) |
| `:v1.5.3153.0-bf2stats-3.2.0` | [View](variants/v1.5.3153.0-bf2stats-3.2.0 ) |
Expand Down
12 changes: 6 additions & 6 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ To customize the server, edit `serversettings.con` and `maplist.con` accordingly

```sh
# Generate serversettings.con and customize
docker run --rm startersclan/docker-bf2:v1.5.3153.0-bf2stats-2.7.2 cat /server/bf2/mods/bf2/settings/serversettings.con > serversettings.con
docker run --rm startersclan/docker-bf2:v1.5.3153.0-bf2stats-2.8.1 cat /server/bf2/mods/bf2/settings/serversettings.con > serversettings.con
# Generate maplist.con (coop)
docker run --rm startersclan/docker-bf2:v1.5.3153.0-bf2stats-2.7.2 bash -c '(esai-helper -m bf2 get maplist; esai-helper -m xpack get maplist) | grep gpm_coop' > maplist.con
docker run --rm startersclan/docker-bf2:v1.5.3153.0-bf2stats-2.8.1 bash -c '(esai-helper -m bf2 get maplist; esai-helper -m xpack get maplist) | grep gpm_coop' > maplist.con
# Generate maplist.con (conquest)
docker run --rm startersclan/docker-bf2:v1.5.3153.0-bf2stats-2.7.2 bash -c '(esai-helper -m bf2 get maplist; esai-helper -m xpack get maplist) | grep gpm_cq' > maplist.con
docker run --rm startersclan/docker-bf2:v1.5.3153.0-bf2stats-2.8.1 bash -c '(esai-helper -m bf2 get maplist; esai-helper -m xpack get maplist) | grep gpm_cq' > maplist.con
# Generate BF2StatisticsConfig.py and customize
docker run --rm startersclan/docker-bf2:v1.5.3153.0-bf2stats-2.7.2 cat /server/bf2/python/bf2/BF2StatisticsConfig.py > BF2StatisticsConfig.py
docker run --rm startersclan/docker-bf2:v1.5.3153.0-bf2stats-2.8.1 cat /server/bf2/python/bf2/BF2StatisticsConfig.py > BF2StatisticsConfig.py
# BF2 server with BF2Statistics 2.x.x
docker run --rm -it -p 16567:16567/udp -p 29900:29900/udp \
-v "$(pwd)/serversettings.con:/server/bf2/mods/bf2/settings/serversettings.con:ro" \
Expand All @@ -74,7 +74,7 @@ docker run --rm -it -p 16567:16567/udp -p 29900:29900/udp \
--add-host bf2web.gamespy.com:192.168.1.100 \
--add-host gamestats.gamespy.com:192.168.1.100 \
--add-host eapusher.dice.se:192.168.1.100 \
startersclan/docker-bf2:v1.5.3153.0-bf2stats-2.7.2
startersclan/docker-bf2:v1.5.3153.0-bf2stats-2.8.1
```

See `docker-compose` examples:
Expand Down Expand Up @@ -308,7 +308,7 @@ docker run --rm -it -p 16567:16567/udp -p 29900:29900/udp \
--add-host bf2web.gamespy.com:192.168.1.100 \
--add-host gamestats.gamespy.com:192.168.1.100 \
--add-host eapusher.dice.se:192.168.1.100 \
startersclan/docker-bf2:v1.5.3153.0-bf2stats-2.7.2
startersclan/docker-bf2:v1.5.3153.0-bf2stats-2.8.1
```

See `docker-compose` examples:
Expand Down
4 changes: 4 additions & 0 deletions generate/definitions/VARIANTS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ $local:VARIANTS_MATRIX = @(
@{ components = @( 'bf2all64', 'bf2stats-2.5.1' ) }
@{ components = @( 'bf2all64', 'bf2stats-2.6.0' ) }
@{ components = @( 'bf2all64', 'bf2stats-2.7.2' ) }
@{ components = @( 'bf2all64', 'bf2stats-2.8.1' ) }
@{ components = @( 'bf2all64', 'bf2stats-3.1.0' ) }
@{ components = @( 'bf2all64', 'bf2stats-3.1.2' ) }
@{ components = @( 'bf2all64', 'bf2stats-3.2.0' ) }
Expand All @@ -24,6 +25,7 @@ $local:VARIANTS_MATRIX = @(
@{ components = @( 'bf2stats-2.5.1' ) }
@{ components = @( 'bf2stats-2.6.0' ) }
@{ components = @( 'bf2stats-2.7.2' ) }
@{ components = @( 'bf2stats-2.8.1' ) }
@{ components = @( 'bf2stats-3.1.0' ) }
@{ components = @( 'bf2stats-3.1.2' ) }
@{ components = @( 'bf2stats-3.2.0' ) }
Expand Down Expand Up @@ -89,6 +91,8 @@ e07f46f0078fc0dcdbeb0dd86e1e9add4b502b0d7b263711dcad957ec4a6de61 2.5.1.tar.gz
daeb57232cd1725bea3cf45c197fba13d99251864347ffff44552aae585b273a 2.7.0.tar.gz
96a9cd2c1283668e417f45ee14dec6307cbad9f310a81e2e8b5af95a871fef4f 2.7.1.tar.gz
bee8933873b42fff26aff34de964d54f4f470e256be43de7ab30ad122788d605 2.7.2.tar.gz
53927a41279cf904cc8d480fdee6f408a7ab68648a13ee5a313c60b44f58a92c 2.8.0.tar.gz
79083dfba50a3da954ef44a28c4eb07ba01237f305cd5fc6091ae6b6cd628b70 2.8.1.tar.gz
"@
# Since bf2stats 3 python files
# E.g. https://github.com/startersclan/statspython/archive/refs/tags/3.2.0.tar.gz
Expand Down
101 changes: 101 additions & 0 deletions variants/v1.5.3153.0-bf2all64-bf2stats-2.8.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
FROM ubuntu:16.04 as install
ARG TARGETPLATFORM=linux/amd64
ARG BUILDPLATFORM=linux/amd64
RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM"

# Install network utilities which can be useful for debugging issues
# Install unzip and zip for the sake of applying ESAI strategies in ./mods/*/levels/*/server.zip at './GameModes/[gpm_coop|gpm_cq|sp1|sp2|sp3]/[16|32|64]/AI/Strategies.ai'
RUN export DEBIAN_FRONTEND=noninteractive; \
apt-get update; \
apt-get install --no-install-recommends -y \
ca-certificates \
curl \
conntrack dnsutils iproute2 netcat net-tools tcpdump \
unzip zip \
; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*;

# Install Battlefield 2 server
WORKDIR /root
COPY aibehaviours-fixlookatwrapper.ai /aibehaviours-fixlookatwrapper.ai
RUN set -eux; \
curl -sSLO https://files.startersclan.com/ea/bf2/bf2-linuxded-1.5.3153.0-installer.tgz; \
sha256sum bf2-linuxded-1.5.3153.0-installer.tgz | grep "^4d849218c1725e7bd6a7e7f164e27b036248f8ded2e30340dd0722c1dfffbab6 "; \
tar -zxvf bf2-linuxded-1.5.3153.0-installer.tgz; \
sh bf2-linuxded-1.5.3153.0-installer.sh --target /install --noexec --info; \
sh bf2-linuxded-1.5.3153.0-installer.sh --target /install --noexec; \
rm -v bf2-linuxded-1.5.3153.0-installer.sh; \
rm -v bf2-linuxded-1.5.3153.0-installer.tgz; \
cd /install; \
mkdir -p /server; \
# Show the licenses without a pager
cat /install/license.sh | sed 's/^more/cat/' > /install/license-fixed.sh; \
# Agree to licenses
printf '\naccept\n\nyes\n/server\ny\n' | sh /install/license-fixed.sh; \
find /server; \
rm -rf /install; \
# Apply the LookAtWrapper fix to prevent crashes when playing with bots
mv -v /server/bf2/mods/bf2/ai/aibehaviours.ai /server/bf2/mods/bf2/ai/aibehaviours.ai.original; \
cp -v /aibehaviours-fixlookatwrapper.ai /server/bf2/mods/bf2/ai/aibehaviours.ai; \
mv -v /server/bf2/mods/xpack/ai/aibehaviours.ai /server/bf2/mods/xpack/ai/aibehaviours.ai.original; \
cp -v /aibehaviours-fixlookatwrapper.ai /server/bf2/mods/xpack/ai/aibehaviours.ai; \
rm -v /aibehaviours-fixlookatwrapper.ai

# Install bf2all64 mod
WORKDIR /root
COPY aibehaviours-fixlookatwrapper.ai /aibehaviours-fixlookatwrapper.ai
RUN set -eux; \
curl -sSLO https://files.startersclan.com/ea/bf2/bf2all64_v1.0_setup.zip; \
sha256sum bf2all64_v1.0_setup.zip | grep '^4ee82d91043c4afbf1bed50787cbf98af124bd7e6c608cdb0f5115c7761024f1 '; \
unzip bf2all64_v1.0_setup.zip -d extract; \
rm -rf /server/bf2/mods/bf2all64; \
mv extract/bf2all64 /server/bf2/mods; \
rm -fv bf2all64_v1.0_setup.zip; \
# Apply the LookAtWrapper fix to prevent crashes when playing with bots
mv -v /server/bf2/mods/bf2all64/ai/aibehaviours.ai /server/bf2/mods/bf2all64/ai/aibehaviours.ai.original; \
cp -v /aibehaviours-fixlookatwrapper.ai /server/bf2/mods/bf2all64/ai/aibehaviours.ai; \
rm -v /aibehaviours-fixlookatwrapper.ai

# Install bf2stats 2.8.1
WORKDIR /root
RUN set -eux; \
curl -sSLO https://github.com/startersclan/bf2stats/archive/refs/tags/2.8.1.tar.gz; \
echo "79083dfba50a3da954ef44a28c4eb07ba01237f305cd5fc6091ae6b6cd628b70 2.8.1.tar.gz" | sha256sum -c -; \
mkdir -p extract; \
tar -C extract -zxvf 2.8.1.tar.gz; \
rm -rf /server/bf2/python; \
mv extract/bf2stats-2.8.1/src/python /server/bf2/python; \
rm -fv 2.8.1.tar.gz; \
rm -rf extract

# Install ESAI in all mods
WORKDIR /root
COPY ESAI-Standard-v4.2.zip ESAI-Standard-v4.2.zip
COPY lowercase-helper /usr/local/bin/lowercase-helper
RUN set -eux; \
sha256sum ESAI-Standard-v4.2.zip | grep '^ef4e5d0f1446b9a2ddb0b350f1334273681c0f64d9c38c506320db769b24499c '; \
# Lowercase all files in ESAI folder
for i in $( ls /server/bf2/mods ); do \
unzip ESAI-Standard-v4.2.zip -d /server/bf2/mods/$i; \
lowercase-helper --dir "/server/bf2/mods/$i/ESAI"; \
done; \
# Lowercase ESAI mapfiles' content
for i in $( find /server/bf2/mods/*/esai/mapfiles -type f ); do \
CONTENT=$( cat "$i" ); \
echo "$CONTENT" | tr '[:upper:]' '[:lower:]' > "$i"; \
done;

# Install esai-helper and configs
COPY esai-helper /usr/local/bin/esai-helper
COPY esai-optimized-strategies-bf2.txt /esai-optimized-strategies-bf2.txt
COPY esai-optimized-strategies-bf2all64.txt /esai-optimized-strategies-bf2all64.txt
COPY esai-optimized-strategies-xpack.txt /esai-optimized-strategies-xpack.txt

COPY healthcheck /healthcheck

# EXPOSE 16567/udp
# EXPOSE 29900/udp
# HEALTHCHECK CMD /healthcheck
WORKDIR /server/bf2
CMD [ "./start.sh", "+modPath", "mods/bf2all64" ]
Binary file not shown.
Loading

0 comments on commit 4da26d1

Please sign in to comment.