diff --git a/.docker/nginx/nginx.conf b/.docker/nginx/nginx.conf new file mode 100644 index 00000000..66600735 --- /dev/null +++ b/.docker/nginx/nginx.conf @@ -0,0 +1,49 @@ +events { + worker_connections 768; + # multi_accept on; +} + +http { + include mime.types; + include fastcgi.conf; + default_type application/octet-stream; + sendfile on; + tcp_nopush on; + server_tokens off; + client_max_body_size 10M; + gzip on; + gzip_disable "msie6"; + gzip_vary on; + gzip_proxied any; + gzip_comp_level 6; + gzip_buffers 16 8k; + gzip_http_version 1.1; + gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; + + server { + listen 80; + root /app/public; + charset utf-8; + index index.php; + location / { + try_files $uri $uri/ /index.php?$query_string; + } + location = /favicon.ico { access_log off; log_not_found off; } + location = /robots.txt { access_log off; log_not_found off; } + error_page 404 /index.php; + location ~ /\.ht { + deny all; + } + location ~ /\.(?!well-known).* { + deny all; + } + location ~ \.php$ { + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Client-Id,Client-Secret,Cache-Control,Content-Type,Pragma,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With,App-Platform,App-Version,Idempotency-Key' always; + fastcgi_pass php:9000; + fastcgi_index index.php; + } + } +} + diff --git a/.docker/php.Dockerfile b/.docker/php.Dockerfile new file mode 100644 index 00000000..ae1f5d64 --- /dev/null +++ b/.docker/php.Dockerfile @@ -0,0 +1,19 @@ +FROM php:8.1.3-fpm-buster + +WORKDIR /app + +RUN useradd -d /app -s /bin/bash runner + +RUN sed -i 's/user = www-data/user = runner/' /usr/local/etc/php-fpm.d/www.conf +RUN sed -i 's/group = www-data/group = runner/' /usr/local/etc/php-fpm.d/www.conf + +RUN apt-get clean && apt-get update && apt-get install -y apt-utils +RUN apt-get install -y libsodium-dev curl libpng-dev git zip + + +RUN docker-php-ext-install mysqli pdo pdo_mysql sodium bcmath exif gd pcntl + +RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer +RUN rm composer-setup.php + diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..3c3629e6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/config/database.php b/config/database.php index 28d496ae..96f3c022 100644 --- a/config/database.php +++ b/config/database.php @@ -66,11 +66,11 @@ return [ 'mysqltest' => [ 'driver' => 'mysql', 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '3306'), - 'database' => env('DB_TEST_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), + 'host' => env('DB_TEST_HOST', env('DB_HOST', '127.0.0.1')), + 'port' => env('DB_TEST_PORT', env('DB_PORT', '3306')), + 'database' => env('DB_TEST_DATABASE', env('DB_DATABASE', 'forge')), + 'username' => env('DB_TEST_USERNAME', env('DB_USERNAME', 'forge')), + 'password' => env('DB_TEST_PASSWORD', env('DB_PASSWORD', '')), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..71893ad3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,46 @@ +version: '1' +services: + webservice: + image: nginx:1.21.6-alpine + container_name: nginx + depends_on: + - php + ports: + - "8000:80" + volumes: + - ./:/app + - ./storage:/app/storage + - ./.docker/nginx/nginx.conf:/etc/nginx/nginx.conf + php: + build: + context: . + dockerfile: ./.docker/php.Dockerfile + container_name: php + depends_on: + - db + - dbtest + command: php-fpm -F -R + volumes: + - ./:/app + - ./storage:/app/storage + - ./.docker/nginx/nginx.conf:/etc/nginx/nginx.conf + db: + image: mariadb:10.6.5 + container_name: db + environment: + MARIADB_ROOT_PASSWORD: local + MYSQL_PASSWORD: local + MYSQL_DATABASE: db + MYSQL_USER: db + volumes: + - /opt/mysql-docker/scoutrobot-db:/var/lib/mysql + dbtest: + image: mariadb:10.6.5 + container_name: dbtest + environment: + MARIADB_ROOT_PASSWORD: local + MYSQL_PASSWORD: local + MYSQL_DATABASE: db + MYSQL_USER: db + volumes: + - /opt/mysql-docker/scoutrobot-dbtest:/var/lib/mysql