This commit is contained in:
parent
76034f2d7e
commit
0da0f43729
17
Dockerfile
17
Dockerfile
@ -1,18 +1,15 @@
|
||||
# Stage 1: Build Nginx
|
||||
FROM alpine:3.20.3 AS builder
|
||||
|
||||
# Variables
|
||||
ARG NGINX_VERSION="1.27.1"
|
||||
FROM alpine:3.20.3 as builder
|
||||
|
||||
# Install build dependencies and required tools
|
||||
RUN apk update && apk upgrade && \
|
||||
apk add --no-cache build-base pcre-dev openssl-dev zlib-dev linux-headers
|
||||
|
||||
# Download and build Nginx from source
|
||||
# Download and build the latest version of Nginx from source
|
||||
WORKDIR /tmp
|
||||
RUN wget https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
|
||||
tar -xzvf nginx-${NGINX_VERSION}.tar.gz && \
|
||||
cd nginx-${NGINX_VERSION} && \
|
||||
RUN wget https://nginx.org/download/nginx-1.27.0.tar.gz && \
|
||||
tar -xzvf nginx-1.27.0.tar.gz && \
|
||||
cd nginx-1.27.0 && \
|
||||
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin/nginx --conf-path=/etc/nginx/nginx.conf && \
|
||||
make > /dev/null 2>&1 && \
|
||||
make install > /dev/null 2>&1 && \
|
||||
@ -34,7 +31,7 @@ COPY ./docker/index.html /tmp/index.html
|
||||
COPY ./public /tmp/public
|
||||
|
||||
# Stage 2: Create a smaller production image
|
||||
FROM alpine:3.20.3
|
||||
FROM alpine:3.20.3
|
||||
|
||||
# Copy Nginx and PHP-FPM binaries and configurations from the builder stage
|
||||
COPY --from=builder /usr/local/nginx /usr/local/nginx
|
||||
@ -53,4 +50,4 @@ RUN apk update && apk upgrade && \
|
||||
RUN rm -rf /var/cache/apk/*
|
||||
|
||||
# Start server
|
||||
CMD ["sh", "/start.sh"]
|
||||
CMD ["sh", "/start.sh"]
|
@ -23,15 +23,15 @@ else
|
||||
fi
|
||||
|
||||
# Letting php know that we are running in docker
|
||||
echo "env[DOCKER] = true" >> /etc/php81/php-fpm.d/www.conf
|
||||
echo "clear_env = no" >> /etc/php81/php-fpm.d/www.conf
|
||||
echo "env[DOCKER] = true" >> /etc/php83/php-fpm.d/www.conf
|
||||
echo "clear_env = no" >> /etc/php83/php-fpm.d/www.conf
|
||||
|
||||
# Create the directory for PHP socket
|
||||
mkdir -p /run/php
|
||||
|
||||
# Set php-fpm to listen on socket
|
||||
touch /run/php/php.sock
|
||||
sed -i 's/^listen = .*/listen = \/run\/php\/php.sock/' /etc/php81/php-fpm.d/www.conf
|
||||
sed -i 's/^listen = .*/listen = \/run\/php\/php.sock/' /etc/php83/php-fpm.d/www.conf
|
||||
|
||||
echo "Setting permissions for upload script"
|
||||
chmod 777 /var/www/html/upload.php
|
||||
@ -39,8 +39,8 @@ chmod 777 /var/www/html/upload.php
|
||||
echo "Setting max upload size to ${MAX_UPLOAD_SIZE}"
|
||||
|
||||
# Set max upload size for php
|
||||
sed -i "s/^upload_max_filesize = .*/upload_max_filesize = ${MAX_UPLOAD_SIZE}/" /etc/php81/php.ini
|
||||
sed -i "s/^post_max_size = .*/post_max_size = ${MAX_UPLOAD_SIZE}/" /etc/php81/php.ini
|
||||
sed -i "s/^upload_max_filesize = .*/upload_max_filesize = ${MAX_UPLOAD_SIZE}/" /etc/php83/php.ini
|
||||
sed -i "s/^post_max_size = .*/post_max_size = ${MAX_UPLOAD_SIZE}/" /etc/php83/php.ini
|
||||
|
||||
# Set max upload size for nginx
|
||||
sed -i "s/client_max_body_size 500M;/client_max_body_size ${MAX_UPLOAD_SIZE};/" /etc/nginx/nginx.conf
|
||||
|
Loading…
x
Reference in New Issue
Block a user