Skip to content

Commit 8a51afd

Browse files
author
Vianney Veremme
committed
Refactor Dockerfile to remove non-root user setup and adjust health check configuration
1 parent 5a9246f commit 8a51afd

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

Dockerfile

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ ENV TEMP_SQL_DIR=/temp-sql-files
77
# Set the shell for safer execution
88
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
99

10-
# Create a non-root user and group
11-
RUN groupadd -r dbuser && useradd -r -g dbuser dbuser
12-
1310
# Copy all files into a temporary location
1411
COPY . ${TEMP_SQL_DIR}/
1512

@@ -20,16 +17,12 @@ RUN find "${TEMP_SQL_DIR:?}/" -type f -name "*.sql" | while read -r file; do \
2017
done && \
2118
rm -rf "${TEMP_SQL_DIR:?}/"
2219

23-
# Set ownership and adjust permissions on the MySQL data directory
24-
RUN chown -R dbuser:dbuser /docker-entrypoint-initdb.d && \
25-
chown -R dbuser:dbuser /var/lib/mysql /etc/mysql
26-
2720
# Expose the default MariaDB port (3306)
2821
EXPOSE 3306
2922

30-
# Switch to the new user
31-
USER dbuser
23+
# Switch to the mysql user
24+
USER mysql
3225

3326
# Add health check for the container
34-
HEALTHCHECK --interval=1m --timeout=10s --start-period=30s --retries=3 \
35-
CMD mysqladmin ping -h localhost || exit 1
27+
HEALTHCHECK --interval=10s --timeout=5s --start-period=30s --retries=3 \
28+
CMD healthcheck.sh --connect --innodb_initialized || exit 1

0 commit comments

Comments
 (0)