From a6d5316090e0f2c4b6aee50b71b4db0269dcd9d2 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 21 Mar 2022 21:46:49 +0100 Subject: [PATCH] WIP - Persistent storage --- src/lib/buildPacks/common.ts | 2 +- src/lib/buildPacks/php.ts | 2 +- src/lib/queues/builder.ts | 4 +++- src/routes/applications/[id]/storage/_Storage.svelte | 3 +++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib/buildPacks/common.ts b/src/lib/buildPacks/common.ts index 9ded4e0f9..3214f7adf 100644 --- a/src/lib/buildPacks/common.ts +++ b/src/lib/buildPacks/common.ts @@ -135,7 +135,7 @@ export async function copyBaseConfigurationFiles(buildPack, workdir, buildId, ap RewriteRule ^(.+)$ index.php [QSA,L] ` ); - await fs.writeFile(`${workdir}/entrypoint.sh`, `chown -R www-data /app`); + await fs.writeFile(`${workdir}/entrypoint.sh`, `chown -R 1000 /app`); saveBuildLog({ line: 'Copied default configuration file for PHP.', buildId, applicationId }); } else if (staticDeployments.includes(buildPack)) { await fs.writeFile( diff --git a/src/lib/buildPacks/php.ts b/src/lib/buildPacks/php.ts index 0db2dd063..3ac7b4670 100644 --- a/src/lib/buildPacks/php.ts +++ b/src/lib/buildPacks/php.ts @@ -16,7 +16,7 @@ const createDockerfile = async (data, image): Promise => { Dockerfile.push('WORKDIR /app'); Dockerfile.push(`COPY .${baseDirectory || ''} /app`); Dockerfile.push(`COPY /.htaccess .`); - Dockerfile.push(`COPY /entrypoint.sh /entrypoint.sh`); + Dockerfile.push(`COPY /entrypoint.sh /opt/docker/provision/entrypoint.d/30-entrypoint.sh`); Dockerfile.push(`EXPOSE 80`); await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n')); }; diff --git a/src/lib/queues/builder.ts b/src/lib/queues/builder.ts index 1cbef0f85..4a34718c5 100644 --- a/src/lib/queues/builder.ts +++ b/src/lib/queues/builder.ts @@ -70,7 +70,9 @@ export default async function (job) { let volumes = persistentStorage?.map((storage) => { - return `${applicationId}-${storage.id}:${type !== 'docker' ? '/app/' : ''}${storage.path}`; + return `${applicationId}${storage.path.replace(/\//gi, '-')}:${ + type !== 'docker' ? '/app/' : '' + }${storage.path}`; }) || []; // Previews, we need to get the source branch and set subdomain if (pullmergeRequestId) { diff --git a/src/routes/applications/[id]/storage/_Storage.svelte b/src/routes/applications/[id]/storage/_Storage.svelte index d9bdc9ebe..3fa86ef21 100644 --- a/src/routes/applications/[id]/storage/_Storage.svelte +++ b/src/routes/applications/[id]/storage/_Storage.svelte @@ -11,6 +11,9 @@ async function saveStorage() { try { + storage.path = storage.path.startsWith('/') ? storage.path : `/${storage.path}`; + storage.path = storage.path.endsWith('/') ? storage.path.slice(0, -1) : storage.path; + storage.path.replace(/\/\//g, '/'); await post(`/applications/${id}/storage.json`, { path: storage.path });