From f8f17832de35e18408851964302b0545d9d7c85c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 28 Apr 2022 16:31:46 +0200 Subject: [PATCH] WIP Laravel --- src/lib/buildPacks/common.ts | 17 +++++++++++------ src/lib/buildPacks/laravel.ts | 16 ++++++++++------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/lib/buildPacks/common.ts b/src/lib/buildPacks/common.ts index 4c1b6053b..89aa67f99 100644 --- a/src/lib/buildPacks/common.ts +++ b/src/lib/buildPacks/common.ts @@ -184,7 +184,7 @@ export async function copyBaseConfigurationFiles( include /etc/nginx/mime.types; default_type application/octet-stream; - + server { listen 80; server_name localhost; @@ -237,21 +237,22 @@ export async function copyBaseConfigurationFiles( include /etc/nginx/mime.types; default_type application/octet-stream; - + server { listen 80; - server_name localhost; + server_name _; + disable_symlinks off; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; - + + root /app/public; index index.html index.htm index.php; charset utf-8; location / { - root /app/public; try_files $uri $uri/ /index.php?$query_string; } @@ -260,7 +261,11 @@ export async function copyBaseConfigurationFiles( error_page 404 /index.php; - location ~ \.php$ { + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + if (!-f $document_root$fastcgi_script_name) { + return 404; + } fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; diff --git a/src/lib/buildPacks/laravel.ts b/src/lib/buildPacks/laravel.ts index ce44fa7fe..61c2d7f6e 100644 --- a/src/lib/buildPacks/laravel.ts +++ b/src/lib/buildPacks/laravel.ts @@ -9,17 +9,21 @@ const createDockerfile = async (data, image): Promise => { Dockerfile.push(`LABEL coolify.image=true`); Dockerfile.push('WORKDIR /app'); Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`); - Dockerfile.push(`COPY composer.* ./`); - Dockerfile.push(`COPY database/ database/`); + Dockerfile.push(`COPY --chown=application:application composer.* ./`); + Dockerfile.push(`COPY --chown=application:application database/ database/`); Dockerfile.push( `RUN composer install --ignore-platform-reqs --no-interaction --no-plugins --no-scripts --prefer-dist` ); - Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /app/public/js/ /app/public/js/`); - Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /app/public/css/ /app/public/css/`); Dockerfile.push( - `COPY --from=${applicationId}:${tag}-cache /app/mix-manifest.json /app/public/mix-manifest.json` + `COPY --chown=application:application --from=${applicationId}:${tag}-cache /app/public/js/ /app/public/js/` ); - Dockerfile.push(`COPY . ./`); + Dockerfile.push( + `COPY --chown=application:application --from=${applicationId}:${tag}-cache /app/public/css/ /app/public/css/` + ); + Dockerfile.push( + `COPY --chown=application:application --from=${applicationId}:${tag}-cache /app/mix-manifest.json /app/public/mix-manifest.json` + ); + Dockerfile.push(`COPY --chown=application:application . ./`); Dockerfile.push(`EXPOSE 80`); await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n')); };