From a4988d1e938102a9bf0e2196fb5817945957be4a Mon Sep 17 00:00:00 2001 From: Vianney Veremme Date: Fri, 18 Apr 2025 18:30:20 -0400 Subject: [PATCH 1/2] Refactor Dockerfile to run flatten script and add new flatten-sql.sh script for SQL file processing --- Dockerfile | 8 ++------ flatten-sql.sh | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100755 flatten-sql.sh diff --git a/Dockerfile b/Dockerfile index 62b8513..29036d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,12 +10,8 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Copy all files into a temporary location COPY . ${TEMP_SQL_DIR}/ -# Flatten the directory structure and rename files to include folder names -RUN find "${TEMP_SQL_DIR:?}/" -type f -name "*.sql" | while read -r file; do \ - new_name=$(echo "$file" | sed "s|${TEMP_SQL_DIR:?}/||" | sed 's|/|_|g' | sed 's|^_||'); \ - cp "$file" "/docker-entrypoint-initdb.d/$new_name"; \ - done && \ - rm -rf "${TEMP_SQL_DIR:?}/" +# Run the flatten script +RUN chmod +x ${TEMP_SQL_DIR}/flatten-sql.sh && ${TEMP_SQL_DIR}/flatten-sql.sh # Expose the default MariaDB port (3306) EXPOSE 3306 diff --git a/flatten-sql.sh b/flatten-sql.sh new file mode 100755 index 0000000..0ca94ba --- /dev/null +++ b/flatten-sql.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -euo pipefail + +TEMP_SQL_DIR=${TEMP_SQL_DIR:-/temp-sql-files} +INITDB_DIR=${INITDB_DIR:-/docker-entrypoint-initdb.d} + +echo "Flattening SQL files from $TEMP_SQL_DIR to $INITDB_DIR" + +find "${TEMP_SQL_DIR:?}/" -type f -name "*.sql" | while read -r file; do + new_name=$(echo "$file" | sed "s|${TEMP_SQL_DIR:?}/||" | sed 's|/|_|g' | sed 's|^_||') + cp "$file" "${INITDB_DIR}/${new_name}" +done + +rm -rf "${TEMP_SQL_DIR:?}/" From 27c61dffef99c5a8336f1c2b721a58c0b86fafdd Mon Sep 17 00:00:00 2001 From: Vianpyro <10519369+Vianpyro@users.noreply.github.com> Date: Sat, 14 Jun 2025 16:23:23 +0000 Subject: [PATCH 2/2] chore: fix linting issues --- flatten-sql.sh | 4 ++-- github_conf/branch_protection_rules.json | 2 +- super-linter-output/super-linter-summary.md | 12 +++--------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/flatten-sql.sh b/flatten-sql.sh index 0ca94ba..8852abc 100755 --- a/flatten-sql.sh +++ b/flatten-sql.sh @@ -7,8 +7,8 @@ INITDB_DIR=${INITDB_DIR:-/docker-entrypoint-initdb.d} echo "Flattening SQL files from $TEMP_SQL_DIR to $INITDB_DIR" find "${TEMP_SQL_DIR:?}/" -type f -name "*.sql" | while read -r file; do - new_name=$(echo "$file" | sed "s|${TEMP_SQL_DIR:?}/||" | sed 's|/|_|g' | sed 's|^_||') - cp "$file" "${INITDB_DIR}/${new_name}" + new_name=$(echo "$file" | sed "s|${TEMP_SQL_DIR:?}/||" | sed 's|/|_|g' | sed 's|^_||') + cp "$file" "${INITDB_DIR}/${new_name}" done rm -rf "${TEMP_SQL_DIR:?}/" diff --git a/github_conf/branch_protection_rules.json b/github_conf/branch_protection_rules.json index 7dfcef9..e545d76 100644 --- a/github_conf/branch_protection_rules.json +++ b/github_conf/branch_protection_rules.json @@ -2,4 +2,4 @@ "message": "Not Found", "documentation_url": "https://docs.github.com/rest", "status": "404" -} +} \ No newline at end of file diff --git a/super-linter-output/super-linter-summary.md b/super-linter-output/super-linter-summary.md index 899bf68..bf2b125 100644 --- a/super-linter-output/super-linter-summary.md +++ b/super-linter-output/super-linter-summary.md @@ -2,18 +2,12 @@ | Language | Validation result | | -------------------------- | ----------------- | +| BASH | Pass ✅ | +| BASH_EXEC | Pass ✅ | | CHECKOV | Pass ✅ | -| GITHUB_ACTIONS | Pass ✅ | | GITLEAKS | Pass ✅ | | GIT_MERGE_CONFLICT_MARKERS | Pass ✅ | | JSCPD | Pass ✅ | -| JSON | Pass ✅ | -| JSON_PRETTIER | Pass ✅ | -| MARKDOWN | Pass ✅ | -| MARKDOWN_PRETTIER | Pass ✅ | -| NATURAL_LANGUAGE | Pass ✅ | -| SQLFLUFF | Pass ✅ | -| YAML | Pass ✅ | -| YAML_PRETTIER | Pass ✅ | +| SHELL_SHFMT | Pass ✅ | All files and directories linted successfully