Docker

From Bebot Wiki 2
Revision as of 21:05, 5 December 2023 by B3b0tUzR (talk | contribs)
Jump to navigationJump to search
Docker

So using Docker can save you some installation hassle, but you'll need to have it installed properly - depending on system hosting your bot(s) :

Windows => https://docs.docker.com/desktop/install/windows-install/

Linux => https://docs.docker.com/desktop/install/linux-install/

Mac => https://docs.docker.com/desktop/install/mac-install/

Build

Once the software is installed, you'll have to build a container based on Bebot itself + docker elements.

So you can download Bebot code (either from Official/Stable or Sandbox/Dev) as .zip (or using git pull command).

Once done you'll have a Bebot folder in which you will create 2 text files :

Dockerfile (with no extension)

FROM alpine:latest
ENTRYPOINT ["/sbin/tini", "-g", "--"]
CMD ["/bebot/docker-entrypoint.sh"]
RUN apk --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/community/ add \
    php82-cli php82-sqlite3 php82-phar php82-curl php82-sockets php82-pdo php82-pdo_sqlite \
    php82-pdo_mysql php82-mbstring php82-ctype php82-bcmath php82-json php82-posix php82-simplexml \
	php82-dom php82-pcntl php82-zip php82-opcache php82-fileinfo php82-mysqli \
	tini \
    sudo \
    && \
    adduser -h /bebot -s /bin/false -D -H bebot
COPY --chown=bebot:bebot . /bebot
RUN sudo ln -s /usr/bin/php82 /usr/bin/php8
USER bebot
WORKDIR /bebot

docker-entrypoint.sh

#!/bin/ash
# shellcheck shell=dash
errorMessage() {
	echo "$*"
	exit 1
}
EXITCODE=255
while [ "$EXITCODE" -eq 255 ]; do
	trap "" TERM
	# shellcheck disable=SC2086
	/usr/bin/php8  StartBot.php "$@"
	EXITCODE=$?
	trap - TERM
done
exit $EXITCODE

In command line you then move into that folder and send the following command :

docker build -t bebot-buildname .

(you can change "buildname" for anything you like but then you'll replace it below accordingly ^^)

test2

...