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