Skip to content

Commit

Permalink
Merge pull request #92 from simplerisk/minimal-fix
Browse files Browse the repository at this point in the history
simplerisk-minimal: remove protocol from mysql commands
  • Loading branch information
jsokol authored Jul 16, 2024
2 parents 5b35189 + 700e8ad commit bf169bc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 27 deletions.
6 changes: 3 additions & 3 deletions simplerisk-minimal/common/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ delete_db(){
print_log "db_deletion: prepare" "Performing database deletion"

# Needed to separate the GRANT statement from the rest because it was providing a syntax error
exec_cmd "mysql --protocol=socket -u $DB_SETUP_USER -p$DB_SETUP_PASS -h$SIMPLERISK_DB_HOSTNAME -P$SIMPLERISK_DB_PORT <<EOSQL
exec_cmd "mysql -u $DB_SETUP_USER -p$DB_SETUP_PASS -h$SIMPLERISK_DB_HOSTNAME -P$SIMPLERISK_DB_PORT <<EOSQL
SET sql_mode = 'ANSI_QUOTES';
DROP DATABASE \"${SIMPLERISK_DB_DATABASE}\";
USE mysql;
Expand Down Expand Up @@ -139,15 +139,15 @@ db_setup(){

print_log "initial_setup:info" "Applying changes to MySQL database... (MySQL error will be printed to console as guidance)"
# Using sql_mode = ANSI_QUOTES to avoid using backticks
exec_cmd "mysql --protocol=socket -u $DB_SETUP_USER -p$DB_SETUP_PASS -h$SIMPLERISK_DB_HOSTNAME -P$SIMPLERISK_DB_PORT <<EOSQL
exec_cmd "mysql -u $DB_SETUP_USER -p$DB_SETUP_PASS -h$SIMPLERISK_DB_HOSTNAME -P$SIMPLERISK_DB_PORT <<EOSQL
SET sql_mode = 'ANSI_QUOTES';
CREATE DATABASE \"${SIMPLERISK_DB_DATABASE}\";
USE \"${SIMPLERISK_DB_DATABASE}\";
\. ${SCHEMA_FILE}
CREATE USER \"${SIMPLERISK_DB_USERNAME}\"@\"%\" IDENTIFIED BY \"${SIMPLERISK_DB_PASSWORD}\";
EOSQL" "Was not able to apply settings on database. Check error above. Exiting."
# Needed to separate the GRANT statement from the rest because it was providing a syntax error
exec_cmd "mysql --protocol=socket -u $DB_SETUP_USER -p$DB_SETUP_PASS -h$SIMPLERISK_DB_HOSTNAME -P$SIMPLERISK_DB_PORT <<EOSQL
exec_cmd "mysql -u $DB_SETUP_USER -p$DB_SETUP_PASS -h$SIMPLERISK_DB_HOSTNAME -P$SIMPLERISK_DB_PORT <<EOSQL
SET sql_mode = 'ANSI_QUOTES';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER ON \"${SIMPLERISK_DB_DATABASE}\".* TO \"${SIMPLERISK_DB_USERNAME}\"@\"%\";
EOSQL" "Was not able to apply settings on database. Check error above. Exiting."
Expand Down
24 changes: 14 additions & 10 deletions simplerisk-minimal/generate_dockerfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -euo pipefail

readonly MYSQL_KEY_URL='http://repo.mysql.com/RPM-GPG-KEY-mysql-2023'

if [ $# -eq 1 ]; then
release=$1
[ "$release" == "testing" ] && images=('8.1') || images=('8.1' '8.3')
Expand All @@ -23,14 +25,15 @@ LABEL maintainer="Simplerisk <[email protected]>"
WORKDIR /var/www
# Add the apt config package
RUN apt-get update && \
apt-get install -y gnupg2 && \
apt-key adv --keyserver pgp.mit.edu --recv-keys A8D3785C && \
echo "deb http://repo.mysql.com/apt/debian bookworm mysql-8.0" > /etc/apt/sources.list.d/mysql.list
# Installing apt dependencies
RUN apt-get update && \\
# Creating keyring env and installing apt dependencies
RUN mkdir -p /etc/apt/keyrings && \\
apt-get update && \\
apt-get install -y gnupg2 wget && \\
wget -qO - $MYSQL_KEY_URL | gpg --dearmor -o /etc/apt/keyrings/mysql.gpg && \\
echo 'deb [signed-by=/etc/apt/keyrings/mysql.gpg] http://repo.mysql.com/apt/\$(lsb_release -si | tr '[:upper:]' '[:lower:]')/ \$(lsb_release -sc) mysql-8.0' | tee /etc/apt/sources.list.d/mysql.list && \\
apt-key adv --keyserver pgp.mit.edu --recv-keys A8D3785C && \\
echo "deb http://repo.mysql.com/apt/debian bookworm mysql-8.0" > /etc/apt/sources.list.d/mysql.list && \\
apt-get update && \\
apt-get -y install libldap2-dev \\
libicu-dev \\
libcap2-bin \\
Expand Down Expand Up @@ -91,9 +94,10 @@ RUN echo 'upload_max_filesize = 5M' >> /usr/local/etc/php/conf.d/docker-php-uplo
RUN rm -rf /var/www/html && \\
EOF

[ ! $release == "testing" ] && echo " curl -sL https://simplerisk-downloads.s3.amazonaws.com/public/bundles/simplerisk-$release.tgz | tar xz -C /var/www && \\" >> "$image_dir/Dockerfile" || true
# shellcheck disable=SC2015
[ ! "$release" == "testing" ] && echo " curl -sL https://simplerisk-downloads.s3.amazonaws.com/public/bundles/simplerisk-$release.tgz | tar xz -C /var/www && \\" >> "$image_dir/Dockerfile" || true
echo " echo $release > /tmp/version" >> "$image_dir/Dockerfile"
if [ $release == "testing" ]; then
if [ "$release" == "testing" ]; then
cat << EOF >> "$image_dir/Dockerfile"
COPY ./simplerisk/ /var/www/simplerisk
COPY common/simplerisk.sql /var/www/simplerisk/simplerisk.sql
Expand Down
15 changes: 8 additions & 7 deletions simplerisk-minimal/php81/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ LABEL maintainer="Simplerisk <[email protected]>"

WORKDIR /var/www

# Add the apt config package
RUN apt-get update && \
apt-get install -y gnupg2 && \
# Creating keyring env and installing apt dependencies
RUN mkdir -p /etc/apt/keyrings && \
apt-get update && \
apt-get install -y gnupg2 wget && \
wget -qO - http://repo.mysql.com/RPM-GPG-KEY-mysql-2023 | gpg --dearmor -o /etc/apt/keyrings/mysql.gpg && \
echo 'deb [signed-by=/etc/apt/keyrings/mysql.gpg] http://repo.mysql.com/apt/$(lsb_release -si | tr '[:upper:]' '[:lower:]')/ $(lsb_release -sc) mysql-8.0' | tee /etc/apt/sources.list.d/mysql.list && \
apt-key adv --keyserver pgp.mit.edu --recv-keys A8D3785C && \
echo "deb http://repo.mysql.com/apt/debian bookworm mysql-8.0" > /etc/apt/sources.list.d/mysql.list

# Installing apt dependencies
RUN apt-get update && \
echo "deb http://repo.mysql.com/apt/debian bookworm mysql-8.0" > /etc/apt/sources.list.d/mysql.list && \
apt-get update && \
apt-get -y install libldap2-dev \
libicu-dev \
libcap2-bin \
Expand Down
15 changes: 8 additions & 7 deletions simplerisk-minimal/php83/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ LABEL maintainer="Simplerisk <[email protected]>"

WORKDIR /var/www

# Add the apt config package
RUN apt-get update && \
apt-get install -y gnupg2 && \
# Creating keyring env and installing apt dependencies
RUN mkdir -p /etc/apt/keyrings && \
apt-get update && \
apt-get install -y gnupg2 wget && \
wget -qO - http://repo.mysql.com/RPM-GPG-KEY-mysql-2023 | gpg --dearmor -o /etc/apt/keyrings/mysql.gpg && \
echo 'deb [signed-by=/etc/apt/keyrings/mysql.gpg] http://repo.mysql.com/apt/$(lsb_release -si | tr '[:upper:]' '[:lower:]')/ $(lsb_release -sc) mysql-8.0' | tee /etc/apt/sources.list.d/mysql.list && \
apt-key adv --keyserver pgp.mit.edu --recv-keys A8D3785C && \
echo "deb http://repo.mysql.com/apt/debian bookworm mysql-8.0" > /etc/apt/sources.list.d/mysql.list

# Installing apt dependencies
RUN apt-get update && \
echo "deb http://repo.mysql.com/apt/debian bookworm mysql-8.0" > /etc/apt/sources.list.d/mysql.list && \
apt-get update && \
apt-get -y install libldap2-dev \
libicu-dev \
libcap2-bin \
Expand Down

0 comments on commit bf169bc

Please sign in to comment.