Skip to content

Commit 2895f5f

Browse files
committed
simplerisk-minimal: set simplerisk user to run the new command
1 parent 742e5a0 commit 2895f5f

3 files changed

Lines changed: 35 additions & 21 deletions

File tree

simplerisk-minimal/Dockerfile

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,25 @@ WORKDIR /var/www
1818

1919
SHELL [ "/bin/bash", "-o", "pipefail", "-c" ]
2020

21-
# Install required packages, including MySQL client from Debian repos
22-
RUN apt-get update && apt-get install -y --no-install-recommends libldap2-dev libicu-dev libcap2-bin libcurl4-gnutls-dev libpng-dev libzip-dev supervisor cron ca-certificates rsyslog logrotate curl default-mysql-client && apt-get -y autoremove && apt-get -y purge && rm -rf /var/lib/apt/lists/*
21+
# Install required packages, including MySQL client from Debian repos
22+
RUN apt-get update && \
23+
apt-get install -y --no-install-recommends \
24+
libldap2-dev \
25+
libicu-dev \
26+
libcap2-bin \
27+
libcurl4-gnutls-dev \
28+
libpng-dev \
29+
libzip-dev \
30+
supervisor \
31+
cron \
32+
ca-certificates \
33+
rsyslog \
34+
logrotate \
35+
curl \
36+
default-mysql-client && \
37+
apt-get -y autoremove && \
38+
apt-get -y purge && \
39+
rm -rf /var/lib/apt/lists/*
2340

2441
# Configure all PHP extensions
2542
RUN docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu && \
@@ -75,19 +92,18 @@ RUN echo 'upload_max_filesize = 5M' >> /usr/local/etc/php/conf.d/docker-php-uplo
7592
# Cleanup /var/www/, creating Simplerisk user on www-data group and setting up ownerships
7693
RUN rm -rf /var/www/html && \
7794
useradd -G www-data simplerisk && \
78-
chown -R simplerisk:www-data /var/www/simplerisk /etc/apache2 /var/run/ /var/log/apache2 && \
79-
chmod -R 770 /var/www/simplerisk /etc/apache2 /var/run/ /var/log/apache2 && \
95+
mkdir -p /var/log/simplerisk && \
96+
mkdir -p /var/log/supervisor && \
97+
mkdir -p /var/run/supervisor && \
98+
chmod -R 700 /etc/apache2 /var/log/simplerisk /var/run/ /var/www/simplerisk && \
8099
chmod 755 /entrypoint.sh /etc/apache2/foreground.sh && \
81-
mkdir -p /var/log/simplerisk && \
82-
chown -R simplerisk:www-data /var/log/simplerisk && \
83-
mkdir -p /var/log/supervisor && \
84-
mkdir -p /var/run/supervisor
100+
chown -R simplerisk:www-data /etc/apache2 /var/log/apache2 /var/log/simplerisk /var/log/supervisor /var/run/ /var/www/simplerisk
85101

86102
# Data to save
87103
VOLUME [ "/var/log", "/etc/apache2/ssl", "/var/www/simplerisk" ]
88104

89105
# Using simplerisk user from here
90-
#USER simplerisk
106+
USER simplerisk
91107

92108
# Setting up entrypoint
93109
ENTRYPOINT [ "/entrypoint.sh" ]

simplerisk-minimal/common/entrypoint.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ delete_db(){
108108
print_log "db_deletion: prepare" "Performing database deletion"
109109

110110
# Needed to separate the GRANT statement from the rest because it was providing a syntax error
111-
exec_cmd "mysql -u $DB_SETUP_USER -p$DB_SETUP_PASS -h$SIMPLERISK_DB_HOSTNAME -P$SIMPLERISK_DB_PORT <<EOSQL
111+
exec_cmd "mysql --skip-ssl -u $DB_SETUP_USER -p$DB_SETUP_PASS -h$SIMPLERISK_DB_HOSTNAME -P$SIMPLERISK_DB_PORT <<EOSQL
112112
SET sql_mode = 'ANSI_QUOTES';
113113
DROP DATABASE \"${SIMPLERISK_DB_DATABASE}\";
114114
USE mysql;
@@ -138,15 +138,15 @@ db_setup(){
138138

139139
print_log "initial_setup:info" "Applying changes to MySQL database... (MySQL error will be printed to console as guidance)"
140140
# Using sql_mode = ANSI_QUOTES to avoid using backticks
141-
exec_cmd "mysql -u $DB_SETUP_USER -p$DB_SETUP_PASS -h$SIMPLERISK_DB_HOSTNAME -P$SIMPLERISK_DB_PORT <<EOSQL
141+
exec_cmd "mysql --skip-ssl -u $DB_SETUP_USER -p$DB_SETUP_PASS -h$SIMPLERISK_DB_HOSTNAME -P$SIMPLERISK_DB_PORT <<EOSQL
142142
SET sql_mode = 'ANSI_QUOTES';
143143
CREATE DATABASE \"${SIMPLERISK_DB_DATABASE}\";
144144
USE \"${SIMPLERISK_DB_DATABASE}\";
145145
\. ${SCHEMA_FILE}
146146
CREATE USER \"${SIMPLERISK_DB_USERNAME}\"@\"%\" IDENTIFIED BY \"${SIMPLERISK_DB_PASSWORD}\";
147147
EOSQL" "Was not able to apply settings on database. Check error above. Exiting."
148148
# Needed to separate the GRANT statement from the rest because it was providing a syntax error
149-
exec_cmd "mysql -u $DB_SETUP_USER -p$DB_SETUP_PASS -h$SIMPLERISK_DB_HOSTNAME -P$SIMPLERISK_DB_PORT <<EOSQL
149+
exec_cmd "mysql --skip-ssl -u $DB_SETUP_USER -p$DB_SETUP_PASS -h$SIMPLERISK_DB_HOSTNAME -P$SIMPLERISK_DB_PORT <<EOSQL
150150
SET sql_mode = 'ANSI_QUOTES';
151151
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER ON \"${SIMPLERISK_DB_DATABASE}\".* TO \"${SIMPLERISK_DB_USERNAME}\"@\"%\";
152152
EOSQL" "Was not able to apply settings on database. Check error above. Exiting."

simplerisk-minimal/generate_dockerfile.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
set -euo pipefail
44

5-
readonly MYSQL_KEY_URL='https://repo.mysql.com/RPM-GPG-KEY-mysql-2023'
65
SCRIPT_LOCATION="$(dirname "$(readlink -f "$0")")"
76
readonly SCRIPT_LOCATION
87

@@ -41,7 +40,7 @@ WORKDIR /var/www
4140
4241
SHELL [ "/bin/bash", "-o", "pipefail", "-c" ]
4342
44-
# Install required packages, including MySQL client from Debian repos
43+
# Install required packages, including MySQL client from Debian repos
4544
RUN apt-get update && \\
4645
apt-get install -y --no-install-recommends \\
4746
libldap2-dev \\
@@ -125,19 +124,18 @@ RUN echo 'upload_max_filesize = 5M' >> /usr/local/etc/php/conf.d/docker-php-uplo
125124
# Cleanup /var/www/, creating Simplerisk user on www-data group and setting up ownerships
126125
RUN rm -rf /var/www/html && \\
127126
useradd -G www-data simplerisk && \\
128-
chown -R simplerisk:www-data /var/www/simplerisk /etc/apache2 /var/run/ /var/log/apache2 && \\
129-
chmod -R 770 /var/www/simplerisk /etc/apache2 /var/run/ /var/log/apache2 && \\
127+
mkdir -p /var/log/simplerisk && \\
128+
mkdir -p /var/log/supervisor && \\
129+
mkdir -p /var/run/supervisor && \\
130+
chmod -R 700 /etc/apache2 /var/log/simplerisk /var/run/ /var/www/simplerisk && \\
130131
chmod 755 /entrypoint.sh /etc/apache2/foreground.sh && \\
131-
mkdir -p /var/log/simplerisk && \\
132-
chown -R simplerisk:www-data /var/log/simplerisk && \\
133-
mkdir -p /var/log/supervisor && \\
134-
mkdir -p /var/run/supervisor
132+
chown -R simplerisk:www-data /etc/apache2 /var/log/apache2 /var/log/simplerisk /var/log/supervisor /var/run/ /var/www/simplerisk
135133
136134
# Data to save
137135
VOLUME [ "/var/log", "/etc/apache2/ssl", "/var/www/simplerisk" ]
138136
139137
# Using simplerisk user from here
140-
#USER simplerisk
138+
USER simplerisk
141139
142140
# Setting up entrypoint
143141
ENTRYPOINT [ "/entrypoint.sh" ]

0 commit comments

Comments
 (0)