kopia lustrzana https://github.com/magicbug/Cloudlog
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.pull/3318/head
rodzic
531cb1b1e3
commit
3bd31bd65d
|
|
@ -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
|
||||
43
script.sh
43
script.sh
|
|
@ -60,22 +60,37 @@ 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
|
||||
# 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
|
||||
|
||||
# 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
|
||||
# Move the files to the destination directory
|
||||
mv $CONFIG_FILE $DEST_DIR
|
||||
mv $DATABASE_FILE $DEST_DIR
|
||||
|
||||
# Move the files to the destination directory
|
||||
mv $CONFIG_FILE $DEST_DIR
|
||||
mv $DATABASE_FILE $DEST_DIR
|
||||
|
||||
# Delete the /install directory
|
||||
rm -rf /install
|
||||
# Delete the /install directory
|
||||
rm -rf /install
|
||||
fi
|
||||
|
||||
echo "Replacement complete."
|
||||
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue