Updated Dockerfile

This commit is contained in:
Dennis Postma 2025-02-07 23:03:03 +01:00
parent d4c1098a5e
commit aebe21f140
2 changed files with 16 additions and 9 deletions

View File

@ -13,17 +13,17 @@ RUN apk add --no-cache \
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
# Setup MariaDB with proper permissions
RUN mkdir -p /run/mysqld /var/lib/mysql && \
mysql_install_db --user=mysql --datadir=/var/lib/mysql && \
RUN mkdir -p /run/mysqld /var/lib/mysql /var/log/mysql && \
chown -R mysql:mysql /run/mysqld && \
chown -R mysql:mysql /var/lib/mysql && \
chmod 755 /run/mysqld && \
chmod 755 /var/lib/mysql
# Create log directory with proper permissions
RUN mkdir -p /var/log/mysql && \
chown -R mysql:mysql /var/log/mysql && \
chmod 755 /var/log/mysql
chmod 777 /run/mysqld && \
chmod 777 /var/lib/mysql && \
chmod 777 /var/log/mysql && \
mysql_install_db --user=mysql --datadir=/var/lib/mysql && \
touch /var/log/mysql/error.log && \
chown mysql:mysql /var/log/mysql/error.log && \
chmod 666 /var/log/mysql/error.log
WORKDIR /usr/src/app
COPY package*.json ./
@ -42,6 +42,13 @@ RUN adduser appuser mysql && \
touch /var/log/mysql/error.log && \
chown mysql:mysql /var/log/mysql/error.log
# Grant necessary permissions to appuser
RUN adduser appuser mysql && \
# Give full access to mysql directories
chmod -R 777 /var/lib/mysql && \
chmod -R 777 /run/mysqld && \
chmod -R 777 /var/log/mysql
USER appuser
EXPOSE 80 6379 3306

View File

@ -29,7 +29,7 @@ fi
echo "Starting MySQL..."
# Start MariaDB with specific options
mysqld --user=mysql \
mariadbd \
--datadir=/var/lib/mysql \
--pid-file=/run/mysqld/mysqld.pid \
--socket=/run/mysqld/mysqld.sock \