Skip to content

Commit 70d800f

Browse files
authored
Refactor Dockerfile to run flatten script for SQL file processing outside of it (#30)
* Refactor Dockerfile to run flatten script and add new flatten-sql.sh script for SQL file processing * chore: fix linting issues
1 parent 7fee2fb commit 70d800f

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

Dockerfile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
1010
# Copy all files into a temporary location
1111
COPY . ${TEMP_SQL_DIR}/
1212

13-
# Flatten the directory structure and rename files to include folder names
14-
RUN find "${TEMP_SQL_DIR:?}/" -type f -name "*.sql" | while read -r file; do \
15-
new_name=$(echo "$file" | sed "s|${TEMP_SQL_DIR:?}/||" | sed 's|/|_|g' | sed 's|^_||'); \
16-
cp "$file" "/docker-entrypoint-initdb.d/$new_name"; \
17-
done && \
18-
rm -rf "${TEMP_SQL_DIR:?}/"
13+
# Run the flatten script
14+
RUN chmod +x ${TEMP_SQL_DIR}/flatten-sql.sh && ${TEMP_SQL_DIR}/flatten-sql.sh
1915

2016
# Expose the default MariaDB port (3306)
2117
EXPOSE 3306

flatten-sql.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
TEMP_SQL_DIR=${TEMP_SQL_DIR:-/temp-sql-files}
5+
INITDB_DIR=${INITDB_DIR:-/docker-entrypoint-initdb.d}
6+
7+
echo "Flattening SQL files from $TEMP_SQL_DIR to $INITDB_DIR"
8+
9+
find "${TEMP_SQL_DIR:?}/" -type f -name "*.sql" | while read -r file; do
10+
new_name=$(echo "$file" | sed "s|${TEMP_SQL_DIR:?}/||" | sed 's|/|_|g' | sed 's|^_||')
11+
cp "$file" "${INITDB_DIR}/${new_name}"
12+
done
13+
14+
rm -rf "${TEMP_SQL_DIR:?}/"

github_conf/branch_protection_rules.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"message": "Not Found",
33
"documentation_url": "https://docs.github.com/rest",
44
"status": "404"
5-
}
5+
}

super-linter-output/super-linter-summary.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@
22

33
| Language | Validation result |
44
| -------------------------- | ----------------- |
5+
| BASH | Pass ✅ |
6+
| BASH_EXEC | Pass ✅ |
57
| CHECKOV | Pass ✅ |
6-
| GITHUB_ACTIONS | Pass ✅ |
78
| GITLEAKS | Pass ✅ |
89
| GIT_MERGE_CONFLICT_MARKERS | Pass ✅ |
910
| JSCPD | Pass ✅ |
10-
| JSON | Pass ✅ |
11-
| JSON_PRETTIER | Pass ✅ |
12-
| MARKDOWN | Pass ✅ |
13-
| MARKDOWN_PRETTIER | Pass ✅ |
14-
| NATURAL_LANGUAGE | Pass ✅ |
15-
| SQLFLUFF | Pass ✅ |
16-
| YAML | Pass ✅ |
17-
| YAML_PRETTIER | Pass ✅ |
11+
| SHELL_SHFMT | Pass ✅ |
1812

1913
All files and directories linted successfully

0 commit comments

Comments
 (0)