Improve startup script and PHP config in Dockerfile
Dockerfile now configures PHP for larger file uploads and increased resource limits. The startup script checks for existing config files before processing, cleans input variables to remove trailing whitespace, and improves sed usage for reliability.
这个提交包含在:
父节点
531cb1b1e3
当前提交
3bd31bd65d
共有 2 个文件被更改,包括 36 次插入 和 14 次删除
|
|
@ -28,5 +28,12 @@ RUN apt-get update && apt-get install -y \
|
|||
COPY script.sh /usr/local/bin/startup.sh
|
||||
RUN sed -i 's/\r$//' /usr/local/bin/startup.sh && chmod +x /usr/local/bin/startup.sh
|
||||
|
||||
# Configure PHP for larger file uploads (30MB)
|
||||
RUN echo "upload_max_filesize = 30M" >> /usr/local/etc/php/conf.d/uploads.ini \
|
||||
&& echo "post_max_size = 35M" >> /usr/local/etc/php/conf.d/uploads.ini \
|
||||
&& echo "memory_limit = 64M" >> /usr/local/etc/php/conf.d/uploads.ini \
|
||||
&& echo "max_execution_time = 300" >> /usr/local/etc/php/conf.d/uploads.ini \
|
||||
&& echo "max_input_time = 300" >> /usr/local/etc/php/conf.d/uploads.ini
|
||||
|
||||
# Expose port 80
|
||||
EXPOSE 80
|
||||
29
script.sh
29
script.sh
|
|
@ -60,15 +60,29 @@ if [ ! -d "$DEST_DIR" ]; then
|
|||
mkdir -p $DEST_DIR
|
||||
fi
|
||||
|
||||
# Check if configuration has already been processed
|
||||
if [ -f "$DEST_DIR/database.php" ] && [ -f "$DEST_DIR/config.php" ]; then
|
||||
echo "Configuration files already exist, skipping processing..."
|
||||
else
|
||||
echo "Processing configuration files..."
|
||||
|
||||
# Use sed with a different delimiter (`|`) to avoid conflicts with special characters
|
||||
sed -i "s|%DATABASE%|${MYSQL_DATABASE}|g" $DATABASE_FILE
|
||||
sed -i "s|%USERNAME%|${MYSQL_USER}|g" $DATABASE_FILE
|
||||
sed -i "s|%PASSWORD%|${MYSQL_PASSWORD}|g" $DATABASE_FILE
|
||||
sed -i "s|%HOSTNAME%|${MYSQL_HOST}|g" $DATABASE_FILE
|
||||
sed -i "s|%baselocator%|${BASE_LOCATOR}|g" $CONFIG_FILE
|
||||
sed -i "s|%websiteurl%|${WEBSITE_URL}|g" $CONFIG_FILE
|
||||
sed -i "s|%directory%|${DIRECTORY}|g" $CONFIG_FILE
|
||||
# Strip any trailing whitespace/newlines from variables before using them
|
||||
CLEAN_DATABASE=$(echo "${MYSQL_DATABASE}" | tr -d '\r\n')
|
||||
CLEAN_USER=$(echo "${MYSQL_USER}" | tr -d '\r\n')
|
||||
CLEAN_PASSWORD=$(echo "${MYSQL_PASSWORD}" | tr -d '\r\n')
|
||||
CLEAN_HOST=$(echo "${MYSQL_HOST}" | tr -d '\r\n')
|
||||
CLEAN_LOCATOR=$(echo "${BASE_LOCATOR}" | tr -d '\r\n')
|
||||
CLEAN_URL=$(echo "${WEBSITE_URL}" | tr -d '\r\n')
|
||||
CLEAN_DIRECTORY=$(echo "${DIRECTORY}" | tr -d '\r\n')
|
||||
|
||||
sed -i "s|%DATABASE%|${CLEAN_DATABASE}|g" $DATABASE_FILE
|
||||
sed -i "s|%USERNAME%|${CLEAN_USER}|g" $DATABASE_FILE
|
||||
sed -i "s|%PASSWORD%|${CLEAN_PASSWORD}|g" $DATABASE_FILE
|
||||
sed -i "s|%HOSTNAME%|${CLEAN_HOST}|g" $DATABASE_FILE
|
||||
sed -i "s|%baselocator%|${CLEAN_LOCATOR}|g" $CONFIG_FILE
|
||||
sed -i "s|%websiteurl%|${CLEAN_URL}|g" $CONFIG_FILE
|
||||
sed -i "s|%directory%|${CLEAN_DIRECTORY}|g" $CONFIG_FILE
|
||||
|
||||
# Move the files to the destination directory
|
||||
mv $CONFIG_FILE $DEST_DIR
|
||||
|
|
@ -76,6 +90,7 @@ mv $DATABASE_FILE $DEST_DIR
|
|||
|
||||
# Delete the /install directory
|
||||
rm -rf /install
|
||||
fi
|
||||
|
||||
echo "Replacement complete."
|
||||
|
||||
|
|
|
|||
正在加载…
在新工单中引用