Difference between revisions of "Docker"

From Bebot Wiki 2
Jump to navigationJump to search
Line 18: Line 18:
  
 
(no extension)
 
(no extension)
 +
 
Dockerfile
 
Dockerfile
 +
 
<pre>
 
<pre>
 
FROM alpine:latest
 
FROM alpine:latest
Line 35: Line 37:
 
USER bebot
 
USER bebot
 
WORKDIR /bebot
 
WORKDIR /bebot
 +
</pre>
 +
 +
docker-entrypoint.sh
 +
 +
<pre>
 +
#!/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
 
</pre>
 
</pre>
  
 
===== test2 =====
 
===== test2 =====
 
...
 
...

Revision as of 21:03, 5 December 2023

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 :

(no extension)

Dockerfile

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
test2

...