Skip to content

Commit

Permalink
make some optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
madkne-laptop committed Mar 30, 2023
1 parent bbdb5b0 commit d14d6ed
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 101 deletions.
21 changes: 0 additions & 21 deletions 03-PHP/laravel/.htaccess

This file was deleted.

10 changes: 5 additions & 5 deletions 03-PHP/laravel/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
RUN groupadd -g 1000 www && useradd -u 1000 -ms /bin/bash -g www www

# Copy code to /var/www
COPY --chown=www:www-data . /var/www
Expand All @@ -52,8 +51,7 @@ RUN cp docker/php.ini /usr/local/etc/php/conf.d/app.ini
RUN cp docker/nginx.conf /etc/nginx/sites-enabled/default

# PHP Error Log Files
RUN mkdir /var/log/php
RUN touch /var/log/php/errors.log && chmod 777 /var/log/php/errors.log
RUN mkdir -p /var/log/php && touch /var/log/php/errors.log && chmod 777 /var/log/php/errors.log


RUN cp docker/.env.production .env
Expand All @@ -63,10 +61,12 @@ RUN composer install --ignore-platform-reqs --optimize-autoloader --no-dev
RUN chmod +x /var/www/docker/run.sh


EXPOSE 80

ENTRYPOINT ["/var/www/docker/run.sh"]



EXPOSE 80


# CMD ["/usr/sbin/nginx", "-g", "daemon off;"]
8 changes: 7 additions & 1 deletion 03-PHP/laravel/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# PHP-Laravel

## get started

- copy `docker/`, `.htaccess`, `Dockerfile`, `.dockerignore` into laravel root project.

- run command `docker build -t laravel-project .` to build image

- run command `docker run -p 8000:80 --name laravel_project -d laravel-project` to run container
## used tools

- php 8.0
Expand All @@ -13,4 +20,3 @@

- please update `docker/.env.production` by your own settings

- also set `.htaccess` into your `/public` directory
14 changes: 10 additions & 4 deletions 03-PHP/laravel/docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
root /var/www/public;

add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";

index index.php index.html;
Expand All @@ -21,12 +22,17 @@
# try_files $uri =404;
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# # fastcgi_index index.php;
# # include fastcgi_params;
# # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# # fastcgi_param PATH_INFO $fastcgi_path_info;
# # fastcgi_buffering off;
# # fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
# fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
# include fastcgi_params;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param PATH_INFO $fastcgi_path_info;
# fastcgi_buffering off;

# fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
Expand Down
58 changes: 0 additions & 58 deletions 03-PHP/laravel/docker/supervisor copy.conf

This file was deleted.

26 changes: 14 additions & 12 deletions 03-PHP/laravel/docker/supervisor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@ pidfile=/var/run/supervisord.pid
priority=999
programs=nginx,php8-fpm,laravel-schedule,laravel-notification,laravel-queue

[program:nginx]
priority=10
autostart=true
autorestart=true
stderr_logfile_maxbytes=0
stdout_logfile_maxbytes=0
stdout_events_enabled=true
stderr_events_enabled=true
command=/usr/sbin/nginx -g 'daemon off;'
stderr_logfile=/var/log/nginx/error.log
stdout_logfile=/var/log/nginx/access.log

[program:php8-fpm]
priority=5
Expand Down Expand Up @@ -55,4 +44,17 @@ autorestart=true
redirect_stderr=true
process_name=%(program_name)s_%(process_num)02d
stdout_logfile=/var/log/nginx/worker.log
command=php /var/www/artisan queue:work sqs --sleep=3 --tries=3
command=php /var/www/artisan queue:work sqs --sleep=3 --tries=3


[program:nginx]
priority=10
autostart=true
autorestart=true
stderr_logfile_maxbytes=0
stdout_logfile_maxbytes=0
stdout_events_enabled=true
stderr_events_enabled=true
command=/usr/sbin/nginx -g 'daemon off;'
stderr_logfile=/var/log/nginx/error.log
stdout_logfile=/var/log/nginx/access.log

0 comments on commit d14d6ed

Please sign in to comment.