From c2a71368f32ebc15d392aa28bf59def43297a2e6 Mon Sep 17 00:00:00 2001 From: dappnode Date: Tue, 28 May 2019 19:23:44 +0000 Subject: [PATCH 1/4] Advance manifest and docker-compose versions to new version: 0.2.4 --- dappnode_package.json | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dappnode_package.json b/dappnode_package.json index 6dac7ad63..4fdcea8e4 100644 --- a/dappnode_package.json +++ b/dappnode_package.json @@ -1,6 +1,6 @@ { "name": "dappmanager.dnp.dappnode.eth", - "version": "0.2.2", + "version": "0.2.4", "description": "Dappnode package responsible for providing the DappNode Package Manager", "avatar": "/ipfs/QmdT2GX9ybaoE25HBk7is8CDnfn2KaFTpZVkLdfkAQs1PN", "type": "dncore", diff --git a/docker-compose.yml b/docker-compose.yml index 6dbdbcf0b..ce1d412d5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,7 @@ services: build: context: . dockerfile: ./build/Dockerfile - image: 'dappmanager.dnp.dappnode.eth:0.2.2' + image: 'dappmanager.dnp.dappnode.eth:0.2.4' container_name: DAppNodeCore-dappmanager.dnp.dappnode.eth restart: always volumes: From 3ee8492bf0c24ce63765aaa4c71161eb2ad4e065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Antu=C3=B1a=20D=C3=ADez?= Date: Thu, 6 Jun 2019 18:26:53 +0200 Subject: [PATCH 2/4] Identation fixed --- docker-compose.yml | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index ce1d412d5..32d7a158e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,26 +1,25 @@ version: '3.4' networks: - network: - driver: bridge - ipam: - config: - - - subnet: 172.33.0.0/16 + network: + driver: bridge + ipam: + config: + - subnet: 172.33.0.0/16 volumes: - dappmanagerdnpdappnodeeth_data: {} + dappmanagerdnpdappnodeeth_data: {} services: - dappmanager.dnp.dappnode.eth: - build: - context: . - dockerfile: ./build/Dockerfile - image: 'dappmanager.dnp.dappnode.eth:0.2.4' - container_name: DAppNodeCore-dappmanager.dnp.dappnode.eth - restart: always - volumes: - - 'dappmanagerdnpdappnodeeth_data:/usr/src/app/dnp_repo/' - - '/usr/src/dappnode/DNCORE/:/usr/src/app/DNCORE/' - - '/var/run/docker.sock:/var/run/docker.sock' - dns: 172.33.1.2 - networks: - network: - ipv4_address: 172.33.1.7 + dappmanager.dnp.dappnode.eth: + build: + context: . + dockerfile: ./build/Dockerfile + image: 'dappmanager.dnp.dappnode.eth:0.2.4' + container_name: DAppNodeCore-dappmanager.dnp.dappnode.eth + restart: always + volumes: + - 'dappmanagerdnpdappnodeeth_data:/usr/src/app/dnp_repo/' + - '/usr/src/dappnode/DNCORE/:/usr/src/app/DNCORE/' + - '/var/run/docker.sock:/var/run/docker.sock' + dns: 172.33.1.2 + networks: + network: + ipv4_address: 172.33.1.7 \ No newline at end of file From 8997ef37c238699e1eefb8425a85af9c5269a508 Mon Sep 17 00:00:00 2001 From: dapplion Date: Fri, 7 Jun 2019 20:15:01 +0200 Subject: [PATCH 3/4] Limit from transfers to 200MB precompresion and 20MB compressed --- build/src/src/calls/copyFileFrom.js | 46 +++++++++++++++-------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/build/src/src/calls/copyFileFrom.js b/build/src/src/calls/copyFileFrom.js index 8c53e12e1..10883c129 100644 --- a/build/src/src/calls/copyFileFrom.js +++ b/build/src/src/calls/copyFileFrom.js @@ -60,19 +60,6 @@ const copyFileFrom = async ({ id, fromPath }) => { // Copy file from container to local file system await docker.copyFileFrom(containerName, fromPath, toPath); - /** - * Limit max file size until a DAppNode <-> client transport method is adopted - * $ du -s -k app/file.gz - * 12 app/file.gz - */ - const toPathSizeKb = await getFileOrDirSize(toPath); - if (toPathSizeKb > 10e3) { - await shell(`rm -rf ${toPath}`); - throw Error( - `File transfers > ${maxSizeKb} KB are not allowed. Attempting ${toPathSizeKb} KB` - ); - } - /** * Allow directories by automatically compressing them to .tar.gz files * 1. Test if directory @@ -81,6 +68,18 @@ const copyFileFrom = async ({ id, fromPath }) => { */ if (fs.lstatSync(toPath).isDirectory()) { + /** + * Limit max file size until a DAppNode <-> client transport method is adopted + * $ du -s -k app/file.gz + * 12 app/file.gz + */ + const dirSizeKb = await getFileOrDirSize(toPath); + if (dirSizeKb > 200e3) { + await shell(`rm -rf ${toPath}`); + throw Error( + `Dir file transfers > ${maxSizeKb} KB are not allowed. Attempting ${dirSizeKb} KB` + ); + } // Use node.js util to get the file / dir name safely const toPathCompressed = `${toPath}.tar.gz`; /** @@ -92,15 +91,18 @@ const copyFileFrom = async ({ id, fromPath }) => { toPath = toPathCompressed; } - // /** - // * Do NOT allow directories for now - // */ - // if (fs.lstatSync(toPath).isDirectory()) { - // await shell(`rm -rf ${toPath}`); - // throw Error( - // `path ${fromPath} is a directory. Only single files are allowed` - // ); - // } + /** + * Limit max file size until a DAppNode <-> client transport method is adopted + * $ du -s -k app/file.gz + * 12 app/file.gz + */ + const fileSizeKb = await getFileOrDirSize(toPath); + if (fileSizeKb > 20e3) { + await shell(`rm -rf ${toPath}`); + throw Error( + `File transfers > ${maxSizeKb} KB are not allowed. Attempting ${fileSizeKb} KB` + ); + } /** * Converts a file to data URI. From 09c45f93df88d0455b4302edeb0b72f523b91445 Mon Sep 17 00:00:00 2001 From: dapplion Date: Fri, 7 Jun 2019 23:12:10 +0200 Subject: [PATCH 4/4] Use zip instead of tar.gz --- build/Dockerfile | 26 +++++++++++++------------- build/src/src/calls/copyFileFrom.js | 9 +++++---- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index 8766c0412..f94e8022c 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -22,7 +22,7 @@ FROM node:10.15.3-alpine ENV DOCKER_COMPOSE_VERSION 1.20.1 -RUN apk add --no-cache curl bind-dev xz libltdl +RUN apk add --no-cache curl bind-dev xz libltdl zip RUN ALPINE_GLIBC_BASE_URL="https://github.com/sgerrand/alpine-pkg-glibc/releases/download" && \ ALPINE_GLIBC_PACKAGE_VERSION="2.28-r0" && \ @@ -31,16 +31,16 @@ RUN ALPINE_GLIBC_BASE_URL="https://github.com/sgerrand/alpine-pkg-glibc/releases ALPINE_GLIBC_I18N_PACKAGE_FILENAME="glibc-i18n-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \ apk add --no-cache --virtual=.build-dependencies wget ca-certificates && \ wget --no-verbose \ - "https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub" \ - -O "/etc/apk/keys/sgerrand.rsa.pub" && \ + "https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub" \ + -O "/etc/apk/keys/sgerrand.rsa.pub" && \ wget --no-verbose \ - "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \ - "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \ - "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \ + "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \ + "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \ + "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \ apk add --no-cache \ - "$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \ - "$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \ - "$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \ + "$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \ + "$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \ + "$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \ \ rm "/etc/apk/keys/sgerrand.rsa.pub" && \ /usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 "$LANG" || true && \ @@ -51,12 +51,12 @@ RUN ALPINE_GLIBC_BASE_URL="https://github.com/sgerrand/alpine-pkg-glibc/releases rm "/root/.wget-hsts" && \ apk del .build-dependencies && \ rm \ - "$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \ - "$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \ - "$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" + "$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \ + "$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \ + "$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" RUN curl -L https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-Linux-x86_64 > /usr/local/bin/docker-compose \ - && chmod +x /usr/local/bin/docker-compose + && chmod +x /usr/local/bin/docker-compose # Copy files and do things that can change diff --git a/build/src/src/calls/copyFileFrom.js b/build/src/src/calls/copyFileFrom.js index 10883c129..419358a40 100644 --- a/build/src/src/calls/copyFileFrom.js +++ b/build/src/src/calls/copyFileFrom.js @@ -81,12 +81,13 @@ const copyFileFrom = async ({ id, fromPath }) => { ); } // Use node.js util to get the file / dir name safely - const toPathCompressed = `${toPath}.tar.gz`; + const toPathCompressed = `${toPath}.zip`; /** - * Use the -C option to cd in directory before doing the tar - * `tar -czf not/hello.tar.gz -C not hello` + * To preserve the folder's relative structure while calling zip from a different dir + * Ref: https://unix.stackexchange.com/a/77616 + * `(cd test/npm-test && zip -r - .) > npm-test.zip` */ - await shell(`tar -czf ${toPathCompressed} -C ${tempTransferDir} ${base}`); + await shell(`(cd ${toPath} && zip -r - .) > ${toPathCompressed}`); await shell(`rm -rf ${toPath}`); toPath = toPathCompressed; }