Skip to content

Instantly share code, notes, and snippets.

@samunders-core
Last active November 24, 2019 22:09
Show Gist options
  • Save samunders-core/089b081707576c2692ce6c52a411aea2 to your computer and use it in GitHub Desktop.
Save samunders-core/089b081707576c2692ce6c52a411aea2 to your computer and use it in GitHub Desktop.
Alpine linux-based openra dedicated server container (~ 315MB)
# wget -O - https://gist.github.com/samunders-core/089b081707576c2692ce6c52a411aea2/raw/ |\
# sed -re '/(FROM|MAINTAINER|RUN)/d' -e 's|ENV|export|' -e '$a su -s /bin/sh ${U}' -e '/^EXPOSE/,$d' | /bin/sh
#
# # execute following as ${U}:
# sed -re '1{s|$|\npgrep -f "mono.*OpenRA.Server.exe.*Mod=" \&\& exit 0\ncd '"${B}"'\nexec\\|;p} 1,/while true; do/d; /done/,$d' ${B}/launch-dedicated.sh > ${H}/${U}.sh\
# chmod +x ${H}/${U}.sh && echo "* * * * * ${H}/${U}.sh" | crontab - && exit
FROM alpine:latest
MAINTAINER sam_
ENV V=release-20171014
ENV U=openra
ENV H=/home/${U}
ENV B=${H}/OpenRA-${V}
RUN \
adduser -h ${H} -s /sbin/nologin -D ${U} && \
mkdir -p ${H}/.openra/Logs && \
mkdir ${H}/.openra/maps
RUN \
echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories && \
apk update && \
apk add mono libgdiplus build-base curl lua && \
curl -L https://github.com/OpenRA/OpenRA/archive/${V}.tar.gz | tar xzf - -C ${H} && \
ln -s /usr/lib/liblua.so.5.1.* /usr/lib/liblua.so.5.1 && \
cd ${B} && make version VERSION=${V} && make && \
apk del build-base curl && \
chown -R ${U}:${U} ${H}
ENV Name="Dedicated Server"
ENV Mod=cnc
ENV ListenPort=1234
ENV AdvertiseOnline=False
ENV Password=
EXPOSE ${ListenPort}
VOLUME [ "${H}/.openra/Logs", "${H}/.openra/maps" ]
USER ${U}
WORKDIR ${B}
ENTRYPOINT exec \
/usr/bin/mono --debug OpenRA.Server.exe Game.Mod=${Mod} Server.Name="${Name}" \
Server.ListenPort=${ListenPort} Server.ExternalPort=${ListenPort} \
Server.AdvertiseOnline=${AdvertiseOnline} \
Server.EnableSingleplayer=False Server.Password=${Password}
#ENTRYPOINT exec ${B}/launch-dedicated.sh
@samunders-core
Copy link
Author

Make your server available on https port (443) to "punch-through" corporate firewalls:

# apk add awall && cat /etc/awall/optional/corporate-accessible-openra.json 
{
  "zone": {
    "inet": { "iface": "eth0" }
  },
  "policy": [
    { "in": "_fw", "action": "accept" },
    { "in": "_fw", "out": "inet", "action": "accept" },
    { "in": "inet", "action": "drop" }
  ],
  "service": {
    "openra": { "proto": "tcp", "port": 1234 }
  },
  "filter": [
    {
      "in": "inet",
      "service": "https",
      "action": "accept"
    },
    {
      "in": "inet",
      "out": "_fw",
      "service": "openra",
      "action": "accept"
    }
  ],
  "dnat": [
    {
      "in": "inet",
      "service": "https",
      "to-port": 1234
    }
  ]
}
# awall activate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment