Skip to content

Commit 590a782

Browse files
Another attempt at fixing the Embedded DB Docker image (#388)
1 parent ae75fc1 commit 590a782

File tree

4 files changed

+54
-34
lines changed

4 files changed

+54
-34
lines changed

build/Dockerfile-EmbeddedDB

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ RUN dotnet publish "gaseous-server/gaseous-server.csproj" --use-current-runtime
2323
# RUN mkdir -p out/wwwroot/emulators/EmulatorJS
2424
# RUN wget https://cdn.emulatorjs.org/releases/4.0.12.7z
2525
# RUN 7z x -y -oout/wwwroot/emulators/EmulatorJS 4.0.12.7z
26+
2627
RUN wget --recursive --no-parent https://cdn.emulatorjs.org/latest/
2728
RUN mkdir -p out/wwwroot/emulators/EmulatorJS
2829
RUN cp -fr cdn.emulatorjs.org/latest/* out/wwwroot/emulators/EmulatorJS
@@ -35,10 +36,19 @@ WORKDIR /App
3536
COPY --from=build-env /App/out .
3637

3738
# variables
38-
ENV dbhost=localhost
39-
ENV dbuser=root
40-
ENV dbpass=gaseous
41-
ENV MARIADB_ROOT_PASSWORD=$dbpass
39+
ARG PUID=1000
40+
ARG PGID=1000
41+
ARG dbhost=localhost
42+
ARG dbuser=root
43+
ARG dbpass=gaseous
44+
ARG MARIADB_ROOT_PASSWORD=$dbpass
45+
46+
ENV PUID=${PUID}
47+
ENV PGID=${PGID}
48+
ENV dbhost=${dbhost}
49+
ENV dbuser=${dbuser}
50+
ENV dbpass=${dbpass}
51+
ENV MARIADB_ROOT_PASSWORD=${dbpass}
4252

4353
# install mariadb
4454
RUN DEBIAN_FRONTEND=noninteractive && \
@@ -50,32 +60,18 @@ RUN chmod +x /usr/sbin/start-mariadb.sh
5060
# install supervisord
5161
RUN apt-get install -y supervisor
5262
COPY ../build/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
63+
RUN mkdir -p /var/run/supervisord
64+
RUN mkdir -p /var/log/supervisord
5365

5466
# clean up apt-get
5567
RUN apt-get clean && rm -rf /var/lib/apt/lists
5668

57-
# set user name
58-
ENV USER=gaseous
59-
ENV GROUP=gaseous
60-
61-
# configure user
62-
ENV PUID=1000
63-
ENV PGID=1000
64-
RUN groupadd -g $PGID $USER
65-
RUN useradd -u $PUID -g $GROUP -m $USER -G sudo
66-
RUN usermod -p "*" $USER
67-
68-
# create home directory
69-
RUN mkdir -p /home/$USER/.gaseous-server /var/lib/mysql
70-
71-
# set permissions
72-
RUN chown -R $USER:$GROUP /App /home/$USER/.gaseous-server /var/lib/mysql /run/mysqld
73-
74-
# switch to user
75-
USER $USER
69+
# copy entrypoint
70+
COPY ../build/entrypoint.sh /usr/sbin/entrypoint.sh
71+
RUN chmod +x /usr/sbin/entrypoint.sh
7672

7773
# volumes
78-
VOLUME /home/$USER/.gaseous-server /var/lib/mysql
74+
VOLUME /home/gaseous/.gaseous-server /var/lib/mysql
7975

8076
# start services
81-
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
77+
ENTRYPOINT [ "/usr/sbin/entrypoint.sh" ]

build/entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
# create the user
4+
echo "Creating user gaseous with UID ${PUID} and GID ${PGID}"
5+
groupadd -g ${PGID} gaseous
6+
useradd -u ${PUID} -g ${PGID} -m gaseous -G sudo
7+
usermod -p "*" gaseous
8+
mkdir -p /home/gaseous/.gaseous-server /var/lib/mysql
9+
chown -R ${PUID}:${PGID} /App /home/gaseous/.gaseous-server /var/lib/mysql /run/mysqld
10+
11+
# Start supervisord and services
12+
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf

build/mariadb.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
# start the database server without network or grant tables
44
/usr/sbin/mariadbd --datadir=/var/lib/mysql --skip-grant-tables --skip-networking &
55

66
# wait for the server to start
7-
sleep 2
7+
sleep 5
88

99
# change the root password
1010
mariadb -u root -e "FLUSH PRIVILEGES; ALTER USER 'root'@'localhost' IDENTIFIED BY '$MARIADB_ROOT_PASSWORD'; FLUSH PRIVILEGES;"
1111

1212
# stop the server
13-
sleep 1
13+
sleep 5
1414
killall mariadbd
1515

1616
# start the server normally

build/supervisord.conf

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
[supervisord]
2-
# user=abc
32
nodaemon=true
4-
logfile=/dev/null
5-
logfile_maxbytes=0
6-
pidfile=/var/run/supervisord.pid
7-
loglevel = INFO
3+
logfile=/var/log/supervisord/supervisord.log
4+
logfile_maxbytes=50
5+
logfile_backups=5
6+
pidfile=/var/run/supervisord/supervisord.pid
7+
loglevel = info
8+
9+
[unix_http_server]
10+
file=/var/run/supervisord/supervisor.sock
11+
chmod=0700
12+
13+
[rpcinterface:supervisor]
14+
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
15+
16+
[supervisorctl]
17+
serverurl=unix:///var/run/supervisord/supervisor.sock
818

919
[program:mariadb]
20+
user=gaseous
1021
command=bash -c "/usr/sbin/start-mariadb.sh"
1122
autostart=true
1223
autorestart=true
@@ -15,9 +26,10 @@ stdout_logfile=/dev/fd/1
1526
stdout_logfile_maxbytes=0
1627

1728
[program:gaseous-server]
29+
user=gaseous
1830
command=dotnet /App/gaseous-server.dll
1931
autostart=true
2032
autorestart=true
2133
redirect_stderr=true
2234
stdout_logfile=/dev/fd/1
23-
stdout_logfile_maxbytes=0
35+
stdout_logfile_maxbytes=0

0 commit comments

Comments
 (0)