From adf50d9d690a3af19579fb09a1bf913893efbf03 Mon Sep 17 00:00:00 2001 From: franknstayn Date: Mon, 4 Sep 2023 23:22:33 +0800 Subject: [PATCH] added docker files and update roster form --- Dockerfile | 21 ++++----- default.conf | 27 ----------- docker-compose.yml | 45 +++++++++++++++++++ entrypoint.sh | 5 --- nginx/conf.d/app.conf | 39 ++++++++++++++++ php/local.ini | 2 + .../roster-name-number-size-form.blade.php | 2 + www.conf | 15 ------- 8 files changed, 96 insertions(+), 60 deletions(-) delete mode 100644 default.conf create mode 100644 docker-compose.yml delete mode 100644 entrypoint.sh create mode 100644 nginx/conf.d/app.conf create mode 100644 php/local.ini delete mode 100644 www.conf diff --git a/Dockerfile b/Dockerfile index 232b2bc..2cec03c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,17 +15,15 @@ RUN apk --update --no-cache add \ && docker-php-ext-install gd pdo pdo_mysql zip mcrypt # Set the working directory in the container -WORKDIR /var/www/html +WORKDIR /var/www -# Copy Nginx config -COPY default.conf /etc/nginx/conf.d/default.conf -COPY entrypoint.sh /etc/entrypoint.sh -RUN chmod +x /etc/entrypoint.sh -RUN mkdir -p /run/nginx +# Clear cache +# RUN apt-get clean && rm -rf /var/lib/apt/lists/* # Copy the Laravel application files to the container COPY . . + # Set appropriate permissions for Laravel storage and bootstrap cache RUN chown -R www-data:www-data storage bootstrap @@ -33,7 +31,7 @@ RUN chown -R www-data:www-data storage bootstrap RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer # Install Laravel dependencies -RUN composer install +RUN composer install --no-plugins --no-scripts # Generate Laravel application key RUN php artisan key:generate @@ -44,9 +42,6 @@ RUN mkdir -p /run/php && chown www-data:www-data /run/php # Copy the www.conf file to PHP-FPM pool.d directory COPY www.conf /usr/local/etc/php-fpm.d/www.conf -# Expose port 9000 for PHP-FPM -EXPOSE 80 -EXPOSE 9001 - -# Start PHP-FPM -ENTRYPOINT ["/etc/entrypoint.sh"] +# Expose port 9000 and start php-fpm server +EXPOSE 9000 +CMD ["php-fpm"] \ No newline at end of file diff --git a/default.conf b/default.conf deleted file mode 100644 index 781a6f4..0000000 --- a/default.conf +++ /dev/null @@ -1,27 +0,0 @@ -server { - listen 80; - server_name localhost; - - root /var/www/html; - index index.php index.html; - - location / { - try_files $uri $uri/ /index.php?$query_string; - } - - location ~ \.php { - fastcgi_index index.php; - fastcgi_pass unix:/run/php-fpm.sock; - include fastcgi_params; - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - } - - location ~* \.(css|less|js|jpg|png|gif)$ { - add_header Cache-Control "no-cache, no-store, must-revalidate"; - add_header Pragma "no-cache"; - expires 0; - } -} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9ce204e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,45 @@ +version: '3' +services: + + #PHP Service + app: + build: + context: . + dockerfile: Dockerfile + image: digitalocean.com/php + container_name: app + restart: unless-stopped + tty: true + environment: + SERVICE_NAME: app + SERVICE_TAGS: dev + working_dir: /var/www + volumes: + - ./:/var/www + - ./php/local.ini:/usr/local/etc/php/conf.d/local.ini + networks: + - app-network + + #Nginx Service + webserver: + image: nginx:alpine + container_name: webserver + restart: unless-stopped + tty: true + ports: + - "9091:80" + - "443:443" + volumes: + - ./:/var/www + - ./nginx/conf.d/:/etc/nginx/conf.d/ + networks: + - app-network + +#Docker Networks +networks: + app-network: + driver: bridge +#Volumes +volumes: + dbdata: + driver: local \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100644 index 7636288..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env sh -set -e - -php-fpm -D -nginx -g 'daemon off;' \ No newline at end of file diff --git a/nginx/conf.d/app.conf b/nginx/conf.d/app.conf new file mode 100644 index 0000000..501fb8a --- /dev/null +++ b/nginx/conf.d/app.conf @@ -0,0 +1,39 @@ +server { + listen 80; + index index.php index.html; + error_log /var/log/nginx/error.log; + access_log /var/log/nginx/access.log; + root /var/www; + index index.php index.html; + + location / { + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE, HEAD'; + add_header 'Access-Control-Max-Age' '1728000'; + add_header 'Access-Control-Allow-Headers' '*'; + #add_header 'Content-Type: text/plain; charset=UTF-8'; + #add_header 'Content-Length: 0'; + return 204; + } + try_files $uri $uri/ /index.php?$query_string; + + } + location ~ \.php$ { + fastcgi_index index.php; + fastcgi_pass app:9000; + + include fastcgi_params; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + + } + location ~* \.(css|less|js|jpg|png|gif)$ { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + add_header Pragma "no-cache"; + expires 0; + } + +} \ No newline at end of file diff --git a/php/local.ini b/php/local.ini new file mode 100644 index 0000000..2f65e19 --- /dev/null +++ b/php/local.ini @@ -0,0 +1,2 @@ +upload_max_filesize=40M +post_max_size=40M \ No newline at end of file diff --git a/resources/views/teamstore-sublayouts/forms/roster-name-number-size-form.blade.php b/resources/views/teamstore-sublayouts/forms/roster-name-number-size-form.blade.php index 8d1f50e..66359ed 100644 --- a/resources/views/teamstore-sublayouts/forms/roster-name-number-size-form.blade.php +++ b/resources/views/teamstore-sublayouts/forms/roster-name-number-size-form.blade.php @@ -15,6 +15,7 @@ + @foreach($sizes_array as $size) @endforeach diff --git a/www.conf b/www.conf deleted file mode 100644 index be77822..0000000 --- a/www.conf +++ /dev/null @@ -1,15 +0,0 @@ -; www.conf -[www] -listen = /run/php-fpm.sock -listen.owner = www-data -listen.group = www-data -listen.mode = 0660 - -user = www-data -group = www-data - -pm = dynamic ; You can choose 'static', 'dynamic', or 'ondemand' -pm.max_children = 5 ; Adjust as needed -pm.start_servers = 2 ; Adjust as needed -pm.min_spare_servers = 1 ; Adjust as needed -pm.max_spare_servers = 3 ; Adjust as needed