diff --git a/.github/workflows/BuildDockerOnTag-Release.yml b/.github/workflows/BuildDockerOnTag-Release.yml index 118ce75..33d54c6 100644 --- a/.github/workflows/BuildDockerOnTag-Release.yml +++ b/.github/workflows/BuildDockerOnTag-Release.yml @@ -59,5 +59,7 @@ jobs: platforms: linux/amd64,linux/arm64 push: true tags: | + gaseousgames/gaseousserver:latest-embeddeddb gaseousgames/gaseousserver:${{ github.ref_name}}-embeddeddb + ghcr.io/gaseous-project/gaseousserver:latest-embeddeddb ghcr.io/gaseous-project/gaseousserver:${{ github.ref_name}}-embeddeddb diff --git a/build/Dockerfile-EmbeddedDB b/build/Dockerfile-EmbeddedDB index b738eaf..cd2f4a1 100644 --- a/build/Dockerfile-EmbeddedDB +++ b/build/Dockerfile-EmbeddedDB @@ -54,8 +54,28 @@ COPY ../build/supervisord.conf /etc/supervisor/conf.d/supervisord.conf # clean up apt-get RUN apt-get clean && rm -rf /var/lib/apt/lists +# set user name +ENV USER=gaseous +ENV GROUP=gaseous + +# configure user +ENV PUID=1000 +ENV PGID=1000 +RUN groupadd -g $PGID $USER +RUN useradd -u $PUID -g $GROUP -m $USER -G sudo +RUN usermod -p "*" $USER + +# create home directory +RUN mkdir -p /home/$USER/.gaseous-server /var/lib/mysql + +# set permissions +RUN chown -R $USER:$GROUP /App /home/$USER/.gaseous-server /var/lib/mysql /run/mysqld + +# switch to user +USER $USER + # volumes -VOLUME /root/.gaseous-server /var/lib/mysql +VOLUME /home/$USER/.gaseous-server /var/lib/mysql # start services CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/build/mariadb.sh b/build/mariadb.sh index 9851661..5db51b7 100644 --- a/build/mariadb.sh +++ b/build/mariadb.sh @@ -1,9 +1,17 @@ #!/bin/bash -# Wait for the service to start -while ! mysqladmin ping -h localhost --silent; do - sleep 1 -done +# start the database server without network or grant tables +/usr/sbin/mariadbd --datadir=/var/lib/mysql --skip-grant-tables --skip-networking & -# Set the root password -mariadb -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$MARIADB_ROOT_PASSWORD';" \ No newline at end of file +# wait for the server to start +sleep 2 + +# change the root password +mariadb -u root -e "FLUSH PRIVILEGES; ALTER USER 'root'@'localhost' IDENTIFIED BY '$MARIADB_ROOT_PASSWORD'; FLUSH PRIVILEGES;" + +# stop the server +sleep 1 +killall mariadbd + +# start the server normally +/usr/sbin/mariadbd --datadir=/var/lib/mysql diff --git a/build/supervisord.conf b/build/supervisord.conf index 533b4c6..acf9971 100644 --- a/build/supervisord.conf +++ b/build/supervisord.conf @@ -1,5 +1,5 @@ [supervisord] -user=root +# user=abc nodaemon=true logfile=/dev/null logfile_maxbytes=0 @@ -7,17 +7,9 @@ pidfile=/var/run/supervisord.pid loglevel = INFO [program:mariadb] -command=/usr/sbin/mariadbd --user=root -autostart=true -autorestart=true -redirect_stderr=true -stdout_logfile=/dev/fd/1 -stdout_logfile_maxbytes=0 - -[program:mariadb-setup] command=bash -c "/usr/sbin/start-mariadb.sh" autostart=true -autorestart=false +autorestart=true redirect_stderr=true stdout_logfile=/dev/fd/1 stdout_logfile_maxbytes=0