Changes for Docker

This commit is contained in:
fatihalp 2023-05-23 21:00:19 +03:00
parent 4973bd08e8
commit 6adf68474b
9 changed files with 2014 additions and 66 deletions

9
.gitignore vendored
View File

@ -1 +1,10 @@
.idea .idea
.env
.coverage
/bin
/core
/build
/vendor
/coverage
/node_modules
/bower_components

View File

@ -1,36 +1,25 @@
#docker compose build --no-cache && docker compose up --force-recreate -d
#docker compose down -v && docker compose up --build
FROM php:7.4-fpm as php FROM php:7.4-fpm as php
ENV PHP_OPCACHE_ENABLE=1
ENV PHP_OPCACHE_ENABLE_CLI=1
ENV PHP_OPCACHE_VALIDATE_TIMESTAMPS=1
ENV PHP_OPCACHE_REVALIDATE_FREQ=1
RUN usermod -u 1000 www-data RUN usermod -u 1000 www-data
RUN apt-get update -y RUN apt-get update -y
RUN apt-get install -y unzip libpq-dev libcurl4-gnutls-dev nginx RUN apt-get install -y unzip libpq-dev libcurl4-gnutls-dev
RUN docker-php-ext-install pdo pdo_mysql bcmath curl opcache RUN docker-php-ext-install pdo pdo_mysql bcmath
RUN docker-php-ext-enable opcache
WORKDIR /var/www WORKDIR /var/www
COPY --chown=www-data:www-data --chmod=777 . . COPY --chown=www-data:www-data --chmod=777 . .
COPY ./docker/php/php.ini /usr/local/etc/php/php.ini #COPY ./docker/php/php.ini /usr/local/etc/php/php.ini
COPY ./docker/php/php-fpm.conf /usr/local/etc/php-fpm.d/www.conf
COPY ./docker/php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
COPY ./docker/nginx/site.conf /etc/nginx/default.conf
#COPY ./docker/php/php.ini /usr/local/etc/php/php.ini
#COPY ./docker/php/php-fpm.conf /usr/local/etc/php-fpm.d/www.conf
#COPY ./docker/nginx/site.conf /etc/nginx/default.conf
COPY ./docker/nginx/nginx.conf /etc/nginx/nginx.conf
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
RUN chmod -R 777 /var/www/storage ENTRYPOINT [ "docker/entrypoint.sh" ]
RUN chmod -R 777 /var/www/bootstrap
#ENTRYPOINT [ "docker/entrypoint.sh" ] #CMD ["docker/entrypoint.sh","php-fpm","-F"]
CMD ["docker/entrypoint.sh","php-fpm","-F"]

View File

@ -58,6 +58,7 @@
"anomaly/dashboard-module": "~2.2.0", "anomaly/dashboard-module": "~2.2.0",
"anomaly/redirects-module": "~2.3.0", "anomaly/redirects-module": "~2.3.0",
"anomaly/settings-module": "~2.4.0", "anomaly/settings-module": "~2.4.0",
"anomaly/search-module": "~3.0.0",
"anomaly/users-module": "~2.5.0", "anomaly/users-module": "~2.5.0",
"anomaly/pages-module": "~2.6.0", "anomaly/pages-module": "~2.6.0",
"anomaly/posts-module": "~2.6.0", "anomaly/posts-module": "~2.6.0",

View File

@ -1,8 +1,7 @@
version: '3' version: '3.8'
networks: networks:
webapp: webapp:
driver: bridge
services: services:
nginx: nginx:
@ -14,7 +13,7 @@ services:
- php - php
volumes: volumes:
- ./:/var/www - ./:/var/www
- ./docker/nginx/site.conf:/etc/nginx/conf.d/default.conf:rw # - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:rw
- ./docker/logs/nginx:/var/logs/nginx:rw - ./docker/logs/nginx:/var/logs/nginx:rw
depends_on: depends_on:
- php - php
@ -47,7 +46,7 @@ services:
image: mysql:8.0 image: mysql:8.0
container_name: ${APP_NAME}_database container_name: ${APP_NAME}_database
ports: ports:
- 3306:3306 - "3306:3306"
command: --max_allowed_packet=32505856 # Set max_allowed_packet to 256M (or any other value) command: --max_allowed_packet=32505856 # Set max_allowed_packet to 256M (or any other value)
environment: environment:
- MYSQL_DATABASE=oc - MYSQL_DATABASE=oc
@ -56,7 +55,7 @@ services:
- MYSQL_ROOT_PASSWORD=oc - MYSQL_ROOT_PASSWORD=oc
- DB_HOST=host.docker.internal - DB_HOST=host.docker.internal
volumes: volumes:
- db-data:/var/lib/mysql - db-data:/var/lib/mysql:delegated
healthcheck: healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"] test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
timeout: 5s timeout: 5s

View File

@ -21,14 +21,8 @@ role=${CONTAINER_ROLE:-app}
if [ "$role" = "app" ]; then if [ "$role" = "app" ]; then
if [ "$INSTALLED" = "false" ]; then if [ "$INSTALLED" = "false" ]; then
echo ".env installed is false starting installing" echo ".env installed is false starting installing"
composer update
php artisan install --ready php artisan install --ready
fi fi
php artisan cache:clear
php artisan config:clear
php artisan route:clear
chmod -R 777 /var/www/storage
chmod -R 777 /var/www/bootstrap
exec docker-php-entrypoint "$@" exec docker-php-entrypoint "$@"
elif [ "$role" = "queue" ]; then elif [ "$role" = "queue" ]; then
echo "Running the queue ... " echo "Running the queue ... "

View File

@ -15,6 +15,31 @@ http {
server_tokens off; server_tokens off;
upstream php-fpm { upstream php-fpm {
server php:9000; server 127.0.0.1:9000 max_fails=5 fail_timeout=5s;
}
server {
listen 8000;
server_name example.com;
root /var/www/public;
index index.php;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
include /etc/nginx/mime.types;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass php-fpm;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
} }
} }

View File

@ -1,25 +0,0 @@
server {
listen 80;
index index.php index.html;
server_name localhost;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/public;
client_max_body_size 100M;
fastcgi_read_timeout 1800;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,15 @@ echo "================================================"
if [[ $(which docker) && $(docker --version) ]]; then if [[ $(which docker) && $(docker --version) ]]; then
docker --version docker --version
#if ubuntu install docker
if [ -n "$(uname -a | grep Ubuntu)" ]; then
if ! docker info > /dev/null 2>&1; then
systemctl --user start docker-desktop
echo "Docker is not running. I've started for you. Run it again"
exit
fi
fi
else else
#if ubuntu install docker #if ubuntu install docker
if [ -n "$(uname -a | grep Ubuntu)" ]; then if [ -n "$(uname -a | grep Ubuntu)" ]; then
@ -32,12 +41,13 @@ fi
cp -u .env-sail .env cp -u .env-sail .env
#docker compose build docker compose build
#--no-cache #--no-cache
docker compose up --force-recreate -d docker compose up -d
docker exec -it oc_php php artisan install --ready #
#docker exec -it oc_php php artisan install --ready
#php artisan migrate --all-addons --force #php artisan migrate --all-addons --force