FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install -y \
    curl \
    ca-certificates \
    lib32gcc-s1 \
    lib32stdc++6 \
    unzip \
    && rm -rf /var/lib/apt/lists/*

RUN mkdir -p /steamcmd /hlds

WORKDIR /steamcmd

RUN curl -sSL https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz | tar -xz

RUN ./steamcmd.sh +login anonymous \
    +force_install_dir /hlds \
    +app_update 90 validate \
    +quit

RUN mkdir -p /root/.steam/sdk32 && \
    ln -sf /hlds/steamclient.so /root/.steam/sdk32/steamclient.so

COPY rehlds/ /hlds/
RUN chmod +x /hlds/hlds_linux
RUN rm -f /hlds/steamclient.so /hlds/libsteam_api.so /hlds/steam_api.so

COPY start.sh /start.sh
RUN chmod +x /start.sh
ENTRYPOINT ["/start.sh"]

EXPOSE 27015/udp
EXPOSE 27020/udp

SHELL ["/bin/bash", "-c"]