Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure DB Files #11

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,25 @@ FROM mariadb:11.5.2

# Set environment variables
ENV TZ=America/Montreal
ENV TEMP_SQL_DIR=/temp-sql-files

# Set the shell for safer execution
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Create a non-root user and group
RUN groupadd -r dbuser && useradd -r -g dbuser dbuser

# Copy SQL files and set ownership
COPY *.sql /docker-entrypoint-initdb.d/
# 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:?}/"

# Set ownership
RUN chown -R dbuser:dbuser /docker-entrypoint-initdb.d

# Ensure proper permissions for MariaDB directories
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.