-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
110 lines (101 loc) · 4.82 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
ARG DEBIANVERSION="bookworm-slim"
ARG ARSVERSION="latest"
ARG GITHUBOWNER="bestnaf"
ARG GITHUBREPO="ARS"
ARG GBINSTALLLOC="/opt/gunbot"
ARG GBMOUNT="/mnt/gunbot"
ARG ARS="ARS_lin.zip"
ARG GUNBOTVERSION
ARG GBPORT=5000
ARG MAINTAINER="computeronix"
ARG WEBSITE="https://hub.docker.com/r/computeronix/ars"
ARG DESCRIPTION="(Unofficial) ARS Docker Container - ${GUNBOTVERSION} - ${ARSVERSION}
#SCRATCH WORKSPACE FOR BUILDING IMAGE
FROM --platform="linux/amd64" debian:${DEBIANVERSION} AS ars-builder
ARG ARSVERSION
ARG GITHUBOWNER
ARG GITHUBREPO
ARG GBINSTALLLOC
ARG GBMOUNT
WORKDIR /tmp
#BUILDING IMAGE
#update mirrors and install packages
RUN apt-get update && apt-get install -y wget jq unzip \
#remove mirrors
&& rm -rf /var/lib/apt/lists/* \
#pull ${ARSVERSION} from official GitHub and extract linux client
&& wget -q -nv -O ars.zip $(wget -q -nv -O- https://api.github.com/repos/${GITHUBOWNER}/${GITHUBREPO}/releases/${ARSVERSION} 2>/dev/null | jq -r '.assets[] | select(.browser_download_url | contains("lin.zip")) | .browser_download_url') \
&& unzip -d . ars.zip \
&& mkdir -p gunbot/ARS \
&& mv Lin/* gunbot/ARS \
#check for local replacement ars.zip and inject if so
&& printf "if [ -f ${GBMOUNT}/ars.zip ]; then \n" >> gunbot/custom.sh \
&& printf " rm -rf ${GBINSTALLLOC}/Lin \n" >> gunbot/custom.sh \
&& printf " unzip -d ${GBINSTALLLOC} ${GBMOUNT}/ars.zip \n" >> gunbot/custom.sh \
&& printf " rm -rf ${GBINSTALLLOC}/ARS \n" >> gunbot/custom.sh \
&& printf " mkdir ${GBINSTALLLOC}/ARS \n" >> gunbot/custom.sh \
&& printf " cp -rf ${GBINSTALLLOC}/Lin/* ${GBINSTALLLOC}/ARS \n" >> gunbot/custom.sh \
&& printf " chmod +x ${GBINSTALLLOC}/ARS/mm_anti_rekt \n" >> gunbot/custom.sh \
&& printf "fi\n" >> gunbot/custom.sh \
#injecting into custom.sh
#check for ARS directory BUT don't link it for persistence
&& printf "if [ ! -d ${GBMOUNT}/ARS ]; then \n" >> gunbot/custom.sh \
&& printf " mkdir ${GBMOUNT}/ARS\n" >> gunbot/custom.sh \
&& printf "fi\n" >> gunbot/custom.sh \
#check for USR_VARS.ini file
&& printf "if [ ! -f ${GBMOUNT}/ARS/USR_VARS.ini ]; then \n" >> gunbot/custom.sh \
&& printf "cp ${GBINSTALLLOC}/ARS/USR_VARS_example.ini ${GBMOUNT}/ARS/USR_VARS.ini\n" >> gunbot/custom.sh \
&& printf "fi\n" >> gunbot/custom.sh \
&& printf "ln -sf ${GBMOUNT}/ARS/USR_VARS.ini ${GBINSTALLLOC}/ARS/USR_VARS.ini\n" >> gunbot/custom.sh \
#check for config.py file
&& printf "if [ ! -f ${GBMOUNT}/ARS/config.py ]; then \n" >> gunbot/custom.sh \
&& printf "wget -q -nv -O /tmp/config.py https://raw.githubusercontent.com/computeronix/docker-ars/master/config_example.py \n" >> gunbot/custom.sh \
&& printf "cp /tmp/config.py ${GBMOUNT}/ARS/config.py\n" >> gunbot/custom.sh \
&& printf "fi\n" >> gunbot/custom.sh \
&& printf "ln -sf ${GBMOUNT}/ARS/config.py ${GBINSTALLLOC}/ARS/config.py\n" >> gunbot/custom.sh \
#check for gunbot_console.log file
&& printf "ln -sf ${GBMOUNT}/gunbot_console.log ${GBINSTALLLOC}/gunbot_console.log\n" >> gunbot/custom.sh \
#ensuring fresh /tmp/USR_VARS_tmp.ini
&& printf "rm -rf /tmp/USR_VARS_tmp.ini\n" >> gunbot/custom.sh \
#inject config -> MM_PATH -> gunbot location
&& printf "input=\"${GBINSTALLLOC}/ARS/USR_VARS.ini\"\n" >> gunbot/custom.sh \
&& printf "while IFS= read -r line\n" >> gunbot/custom.sh \
&& printf "do\n" >> gunbot/custom.sh \
&& printf "if [[ \"\${line}\" == *\"MM_PATH\"* ]]; then\n" >> gunbot/custom.sh \
&& printf " line=\"MM_PATH = ${GBINSTALLLOC}\"\n" >> gunbot/custom.sh \
&& printf "fi\n" >> gunbot/custom.sh \
&& printf "echo \"\${line}\" >> /tmp/USR_VARS_tmp.ini\n" >> gunbot/custom.sh \
&& printf "done < \"\${input}\"\n" >> gunbot/custom.sh \
&& printf "cat /tmp/USR_VARS_tmp.ini > ${GBINSTALLLOC}/ARS/USR_VARS.ini\n" >> gunbot/custom.sh \
#overwrite runner.sh bash script
&& printf "#!/bin/bash\n" > gunbot/runner.sh \
#run gunbot
&& printf "${GBINSTALLLOC}/gunthy-linux > gunbot_console.log 2>&1 &" >> gunbot/runner.sh \
#change working directory to ars
&& printf "cd ${GBINSTALLLOC}/ARS\n" >> gunbot/runner.sh \
#run ars
&& printf "${GBINSTALLLOC}/ARS/mm_anti_rekt\n" >> gunbot/runner.sh
#BUILD THE RUN IMAGE
FROM --platform="linux/amd64" computeronix/gunbot:${GUNBOTVERSION}
ARG MAINTAINER
ARG WEBSITE
ARG DESCRIPTION
ARG GBINSTALLLOC
ARG GBPORT
ENV GUNBOTLOCATION=${GBINSTALLLOC}
LABEL \
maintainer="${MAINTAINER}" \
website="${WEBSITE}" \
description="${DESCRIPTION}"
COPY --from=ars-builder /tmp/gunbot ${GBINSTALLLOC}
WORKDIR ${GBINSTALLLOC}
RUN apt-get update && apt-get install -y wget python3 \
&& apt-get upgrade -y \
&& apt-get autoremove -y \
&& apt-get autoclean -y \
&& rm -rf /var/lib/apt/lists/* \
&& chmod +x "${GBINSTALLLOC}/custom.sh" \
&& chmod +x "${GBINSTALLLOC}/runner.sh" \
&& chmod +x "${GBINSTALLLOC}/ARS/mm_anti_rekt"
EXPOSE ${GBPORT}
CMD ["bash","-c","${GUNBOTLOCATION}/startup.sh"]