server-proxy/Dockerfile

39 lines
2.2 KiB
Docker

FROM sapmachine:21-jre-headless-ubuntu
ENV WORKDIR_PATH=/workspace
ENV CONFIG_PATH=${WORKDIR_PATH}/config
ENV DATA_PATH=${WORKDIR_PATH}/data
ADD ./src ${CONFIG_PATH}
RUN mkdir ${DATA_PATH}
RUN mkdir ${DATA_PATH}/logs && \
ln -sf ${DATA_PATH}/logs ${CONFIG_PATH}
VOLUME ${DATA_PATH}
ENV MEMORY=4G
ENV PROXY_SECRET=00000000-0000-0000-0000-000000000000
ENV SERVERS=lobby="lobby:25565";survival="survival:25565"
ENV TRY=lobby;survival
ENV VOICE_SECRET=00000000-0000-0000-0000-000000000000
ENV VOICE_SERVERS=lobby="lobby:25565";survival="survival:25565"
WORKDIR ${WORKDIR_PATH}/config
EXPOSE 25565/tcp
# TODO: Make awk commands sapn multiple lines
# TODO: Use one call to awk to perform substitutions
CMD \
sed -i "s/_PROXY_SECRET_/${PROXY_SECRET}/g" forwarding.secret && \
cat plugins/plasmovoice/forwarding-secret | sed "s/00000000-0000-0000-0000-000000000000/${VOICE_SECRET}/g" | tr -d '\n' > plugins/plasmovoice/forwarding-secret.tmp && mv -T -f plugins/plasmovoice/forwarding-secret.tmp plugins/plasmovoice/forwarding-secret && \
awk -v servers_str="${VOICE_SERVERS}" '{ count=split(servers_str,servers_arr,";"); servers_fmt_str = ""; for (i = 1; i <= count; i++) servers_fmt_str = servers_fmt_str servers_arr[i] "\n"; sub(/_SERVERS_/,servers_fmt_str); print }' plugins/plasmovoice/config.toml > plugins/plasmovoice/config.toml.tmp && mv -T -f plugins/plasmovoice/config.toml.tmp plugins/plasmovoice/config.toml && \
awk -v servers_str="${SERVERS}" '{ count=split(servers_str,servers_arr,";"); servers_fmt_str = ""; for (i = 1; i <= count; i++) servers_fmt_str = servers_fmt_str servers_arr[i] "\n"; sub(/_SERVERS_/,servers_fmt_str); print }' velocity.toml > velocity.toml.tmp && mv -T -f velocity.toml.tmp velocity.toml && \
awk -v try_str="${TRY}" '{ count=split(try_str,try_arr,";"); try_fmt_str = ""; for (i = 1; i <= count; i++) try_fmt_str = try_fmt_str "\"" try_arr[i] "\"" ",\n "; sub(/_TRY_/,try_fmt_str); print }' velocity.toml > velocity.toml.tmp && mv -T -f velocity.toml.tmp velocity.toml && \
java -Xms${MEMORY} -Xmx${MEMORY} -XX:+UseG1GC -XX:G1HeapRegionSize=4M -XX:+UnlockExperimentalVMOptions -XX:+ParallelRefProcEnabled -XX:+AlwaysPreTouch -XX:MaxInlineLevel=15 -jar *.jar