An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Update buildpacks for static sites
Andras Bacsaif5e7a84fa624
diff --git a/src/lib/buildPacks/common.ts b/src/lib/buildPacks/common.tsindex b1c02867bf..9ded4e0f95 100644--- a/src/lib/buildPacks/common.ts+++ b/src/lib/buildPacks/common.ts@@ -143,27 +143,35 @@ export async function copyBaseConfigurationFiles(buildPack, workdir, buildId, ap`user nginx;worker_processes auto;- error_log /var/log/nginx/error.log warn;- pid /var/run/nginx.pid;+ error_log /docker.stdout;+ pid /run/nginx.pid;events {worker_connections 1024;}http {- include /etc/nginx/mime.types;-- access_log off;- sendfile on;- #tcp_nopush on;- keepalive_timeout 65;+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '+ '$status $body_bytes_sent "$http_referer" '+ '"$http_user_agent" "$http_x_forwarded_for"';++ access_log /docker.stdout main;++ sendfile on;+ tcp_nopush on;+ tcp_nodelay on;+ keepalive_timeout 65;+ types_hash_max_size 2048;++ include /etc/nginx/mime.types;+ default_type application/octet-stream;server {listen 80;server_name localhost;location / {- root /usr/share/nginx/html;+ root /app;index index.html;try_files $uri $uri/index.html $uri/ /index.html =404;}@@ -174,7 +182,7 @@ export async function copyBaseConfigurationFiles(buildPack, workdir, buildId, ap#error_page 500 502 503 504 /50x.html;location = /50x.html {- root /usr/share/nginx/html;+ root /app;}}diff --git a/src/lib/buildPacks/gatsby.ts b/src/lib/buildPacks/gatsby.tsindex a721af1281..38989626df 100644--- a/src/lib/buildPacks/gatsby.ts+++ b/src/lib/buildPacks/gatsby.ts@@ -6,18 +6,17 @@ const createDockerfile = async (data, imageforBuild): Promise<void> => {const Dockerfile: Array<string> = [];Dockerfile.push(`FROM ${imageforBuild}`);- Dockerfile.push('WORKDIR /usr/share/nginx/html');+ Dockerfile.push('WORKDIR /app');Dockerfile.push(`LABEL coolify.image=true`);Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /app/${publishDirectory} ./`);Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);Dockerfile.push(`EXPOSE 80`);- Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));};export default async function (data) {try {- const image = 'nginx:stable-alpine';+ const image = 'webdevops/nginx:alpine';const imageForBuild = 'node:lts';await buildCacheImageWithNode(data, imageForBuild);diff --git a/src/lib/buildPacks/php.ts b/src/lib/buildPacks/php.tsindex 8b9617845a..0db2dd0638 100644--- a/src/lib/buildPacks/php.ts+++ b/src/lib/buildPacks/php.ts@@ -13,10 +13,6 @@ const createDockerfile = async (data, image): Promise<void> => {Dockerfile.push(`RUN chmod +x /usr/local/bin/install-php-extensions`);Dockerfile.push(`RUN /usr/local/bin/install-php-extensions ${data.phpModules.join(' ')}`);}- // Dockerfile.push('RUN a2enmod rewrite');- // Dockerfile.push(`ENV APACHE_DOCUMENT_ROOT /app`);- // Dockerfile.push(`RUN sed -ri -e 's!/var/www/html!/app!g' /etc/apache2/sites-available/*.conf`);- // Dockerfile.push(`RUN sed -ri -e 's!/var/www/!/app!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf`)Dockerfile.push('WORKDIR /app');Dockerfile.push(`COPY .${baseDirectory || ''} /app`);Dockerfile.push(`COPY /.htaccess .`);diff --git a/src/lib/buildPacks/react.ts b/src/lib/buildPacks/react.tsindex 3e372b7765..719f782ebe 100644--- a/src/lib/buildPacks/react.ts+++ b/src/lib/buildPacks/react.ts@@ -7,17 +7,16 @@ const createDockerfile = async (data, image): Promise<void> => {Dockerfile.push(`FROM ${image}`);Dockerfile.push(`LABEL coolify.image=true`);- Dockerfile.push('WORKDIR /usr/share/nginx/html');+ Dockerfile.push('WORKDIR /app');Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /app/${publishDirectory} ./`);Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);Dockerfile.push(`EXPOSE 80`);- Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));};export default async function (data) {try {- const image = 'nginx:stable-alpine';+ const image = 'webdevops/nginx:alpine';const imageForBuild = 'node:lts';await buildCacheImageWithNode(data, imageForBuild);await createDockerfile(data, image);diff --git a/src/lib/buildPacks/static.ts b/src/lib/buildPacks/static.tsindex 20393ac22a..17900ced3a 100644--- a/src/lib/buildPacks/static.ts+++ b/src/lib/buildPacks/static.ts@@ -15,7 +15,7 @@ const createDockerfile = async (data, image): Promise<void> => {const Dockerfile: Array<string> = [];Dockerfile.push(`FROM ${image}`);- Dockerfile.push('WORKDIR /usr/share/nginx/html');+ Dockerfile.push('WORKDIR /app');Dockerfile.push(`LABEL coolify.image=true`);if (secrets.length > 0) {secrets.forEach((secret) => {@@ -39,13 +39,12 @@ const createDockerfile = async (data, image): Promise<void> => {}Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);Dockerfile.push(`EXPOSE 80`);- Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));};export default async function (data) {try {- const image = 'nginx:stable-alpine';+ const image = 'webdevops/nginx:alpine';const imageForBuild = 'node:lts';if (data.buildCommand) await buildCacheImageWithNode(data, imageForBuild);await createDockerfile(data, image);diff --git a/src/lib/buildPacks/svelte.ts b/src/lib/buildPacks/svelte.tsindex 181782b89f..fbcf36abb8 100644--- a/src/lib/buildPacks/svelte.ts+++ b/src/lib/buildPacks/svelte.ts@@ -6,18 +6,17 @@ const createDockerfile = async (data, image): Promise<void> => {const Dockerfile: Array<string> = [];Dockerfile.push(`FROM ${image}`);- Dockerfile.push('WORKDIR /usr/share/nginx/html');+ Dockerfile.push('WORKDIR /app');Dockerfile.push(`LABEL coolify.image=true`);Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /app/${publishDirectory} ./`);Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);Dockerfile.push(`EXPOSE 80`);- Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));};export default async function (data) {try {- const image = 'nginx:stable-alpine';+ const image = 'webdevops/nginx:alpine';const imageForBuild = 'node:lts';await buildCacheImageWithNode(data, imageForBuild);diff --git a/src/lib/buildPacks/vuejs.ts b/src/lib/buildPacks/vuejs.tsindex 7953977cee..fa80ac4353 100644--- a/src/lib/buildPacks/vuejs.ts+++ b/src/lib/buildPacks/vuejs.ts@@ -6,35 +6,19 @@ const createDockerfile = async (data, image): Promise<void> => {const Dockerfile: Array<string> = [];Dockerfile.push(`FROM ${image}`);- Dockerfile.push('WORKDIR /usr/share/nginx/html');+ Dockerfile.push('WORKDIR /app');Dockerfile.push(`LABEL coolify.image=true`);Dockerfile.push(`COPY --from=${applicationId}:${tag}-cache /app/${publishDirectory} ./`);Dockerfile.push(`COPY /nginx.conf /etc/nginx/nginx.conf`);Dockerfile.push(`EXPOSE 80`);- Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));};export default async function (data) {try {- const image = 'nginx:stable-alpine';+ const image = 'webdevops/nginx:alpine';const imageForBuild = 'node:lts';await buildCacheImageWithNode(data, imageForBuild);- // await fs.writeFile(`${data.workdir}/default.conf`, `server {- // listen 80;- // server_name localhost;-- // location / {- // root /usr/share/nginx/html;- // try_files $uri $uri/ /index.html;- // }-- // error_page 500 502 503 504 /50x.html;- // location = /50x.html {- // root /usr/share/nginx/html;- // }- // }- // `);await createDockerfile(data, image);await buildImage(data);} catch (error) {diff --git a/src/lib/queues/builder.ts b/src/lib/queues/builder.tsindex 18985a5fb4..1cbef0f85c 100644--- a/src/lib/queues/builder.ts+++ b/src/lib/queues/builder.ts@@ -52,7 +52,6 @@ export default async function (job) {settings,persistentStorage} = job.data;- console.log(persistentStorage);const { debug } = settings;await asyncSleep(1000);@@ -68,11 +67,10 @@ export default async function (job) {});let imageId = applicationId;let domain = getDomain(fqdn);- const isHttps = fqdn.startsWith('https://');let volumes =persistentStorage?.map((storage) => {- return `${applicationId}-${storage.id}:${storage.path}`;+ return `${applicationId}-${storage.id}:${type !== 'docker' ? '/app/' : ''}${storage.path}`;}) || [];// Previews, we need to get the source branch and set subdomainif (pullmergeRequestId) {@@ -267,7 +265,6 @@ export default async function (job) {}}volumes = volumes.map((volume) => `-v ${volume} `).join();- console.log(volumes);const { stderr } = await asyncExecShell(`DOCKER_HOST=${host} docker run ${envFound && `--env-file=${workdir}/.env`} ${labels.join(' '