Skip to content

Commit

Permalink
Merge pull request #220 from dappnode/v0.2.4
Browse files Browse the repository at this point in the history
v0.2.4 Release
  • Loading branch information
eduadiez authored Jun 7, 2019
2 parents cfca636 + 34bdcaa commit a7dea7e
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 62 deletions.
26 changes: 13 additions & 13 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" && \
Expand All @@ -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 && \
Expand All @@ -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

Expand Down
55 changes: 29 additions & 26 deletions build/src/src/calls/copyFileFrom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -81,26 +68,42 @@ 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`;
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;
}

// /**
// * 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.
Expand Down
2 changes: 1 addition & 1 deletion dappnode_package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dappmanager.dnp.dappnode.eth",
"version": "0.2.3",
"version": "0.2.4",
"description": "Dappnode package responsible for providing the DappNode Package Manager",
"avatar": "/ipfs/QmdT2GX9ybaoE25HBk7is8CDnfn2KaFTpZVkLdfkAQs1PN",
"type": "dncore",
Expand Down
43 changes: 21 additions & 22 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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.3'
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

0 comments on commit a7dea7e

Please sign in to comment.