Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(build): read only a lower-case ADD scheme as remote, like BuildKit
Yudhi Armyndharis99026f31dbb5
diff --git a/scripts/check-dockerignore.mjs b/scripts/check-dockerignore.mjsindex b538701b4..558e3d985 100644--- a/scripts/check-dockerignore.mjs+++ b/scripts/check-dockerignore.mjs@@ -179,7 +179,8 @@ const dockerfile = readFileSync(new URL('Dockerfile', root), 'utf8').replace(/\\\n/g, ' ');const wildcard = /[*?[]/;function copyInputs(source) {- if (/^[a-z][a-z0-9+.-]*:\/\/|^git@/i.test(source)) return [];+ // Remote, as in BuildKit, which matches the scheme in lower case only: ADD HTTPS://x/y names a context path.+ if (/^[a-z][a-z0-9+.-]*:\/\/|^git@/.test(source)) return [];// Docker resolves ./x, /x and x//y against the context root, which is the form the rules match.const path = posix.normalize(source).replace(/^\/+|\/+$/g, '');if (path === '' || path === '.') return [];diff --git a/scripts/check-dockerignore.spec.mjs b/scripts/check-dockerignore.spec.mjsindex c5c655f23..9e4e4dec2 100644--- a/scripts/check-dockerignore.spec.mjs+++ b/scripts/check-dockerignore.spec.mjs@@ -181,6 +181,17 @@ test('a wildcard COPY source is expanded in its own directory, and only its matcassert.doesNotMatch(run.out, /rejects 'sub\/other\.txt'/);});+test('a scheme in capitals is not a URL to BuildKit, so an ADD of it names a context path', () => {+ // Real BuildKit fetches ADD https://host/x.tgz, and looks for the file HTTPS:/host/x.tgz in the context for+ // ADD HTTPS://host/x.tgz, as it does for any scheme that is not in lower case.+ const run = runGate({+ Dockerfile: 'COPY control.txt ./\nADD HTTPS://example.com/x.tgz /opt/\n',+ '.dockerignore': `${REAL_DOCKERIGNORE}\nHTTPS:/example.com/x.tgz\n`,+ });+ assert.equal(run.status, 1, run.out);+ assert.match(run.out, /rejects 'HTTPS:\/example\.com\/x\.tgz'/);+});+test('a wildcard in a directory name is reported instead of guessed', () => {const run = runGate({ Dockerfile: 'COPY su*/x.txt ./\n', '.dockerignore': REAL_DOCKERIGNORE });assert.equal(run.status, 1, run.out);