Skip to content

Commit

Permalink
build: fix build
Browse files Browse the repository at this point in the history
did not build due to missing dependecies, create a docker image that have them predownloaded.
  • Loading branch information
joka90 committed Apr 17, 2021
1 parent 5eb81de commit f2a0ac1
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 8 deletions.
Empty file added .npmignore
Empty file.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM node:10-alpine
FROM node:14-alpine

WORKDIR /
COPY . .

RUN npm install --quiet
RUN apk update && apk add -q git && npm install --quiet

ENTRYPOINT [ "npm", "run-script", "build" ]
ENTRYPOINT [ "npm", "run-script", "build" ]
13 changes: 13 additions & 0 deletions Dockerfile.roborock
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM multiarch/qemu-user-static:x86_64-arm as qemu

FROM arm32v7/node:14-stretch-slim
COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin

RUN apt-get update && apt-get install -y git ca-certificates subversion --no-install-recommends && rm -rf /var/lib/apt/lists/*

# Get prebuilt node binaries and rename them to what node tries to fetch, ugly hack, but work more reliable compared to previous method.
RUN mkdir -p ~/.pkg-cache/ && cd ~/.pkg-cache/ && svn export https://github.com/Hypfer/Valetudo.git/trunk/build_dependencies/pkg/v2.6 && chmod +x ~/.pkg-cache/*/* && rename 's/built/fetched/g' ~/.pkg-cache/*/* && rename 's,v14.16.0,v14.4.0,g' ~/.pkg-cache/*/* && ls -la ~/.pkg-cache/*/*
WORKDIR /src
COPY . .

RUN npm install --quiet
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
PATH := node_modules/.bin:$(PATH)
SHELL := /bin/bash
PKG ?= pkg

.PHONY: all clean
DOCKER ?= docker
.PHONY: all clean docker.roborock build.roborock

all:
npm run build

clean:
rm -f valetudo

docker.roborock:
$(DOCKER) build -t roborock:build -f Dockerfile.roborock .

.in_docker:
bash -c "npm run-script build || cat /root/.npm/_logs/* && ls -la ~/.pkg-cache/*/*"

build.roborock:
$(DOCKER) run -v $(abspath .):/ws -it -t roborock:build bash -c "npm run-script build || cat /root/.npm/_logs/* && ls -la ~/.pkg-cache/*/*"
# bash -c "make -C /ws .in_docker"
10 changes: 9 additions & 1 deletion develop/HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ npm run build
```

You can also create the build with the provider Dockerfile (e.g. when you're on a different OS than Linux). Create the build environment container with:
You need to download the precompiled binaries first

```
svn export https://github.com/Hypfer/Valetudo.git/trunk/build_dependencies
```

then build the container

```
docker build .
```
Expand All @@ -73,7 +81,7 @@ Run the container with
docker run <image_id>
```

Copy the output file from the container with
Copy the output file from the container with (can be found via `docker container ls -a`)
```
docker cp <container_id>:valetudo valetudo
```
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"prebuild": "cp -a client client.b && find client/ -type f \\( -iname \\*.json -o -iname \\*.js -o -iname \\*.html -o -iname \\*.css \\) -exec gzip -9 {} +",
"build": "pkg --targets node12.16.1-linux-armv7 --no-bytecode --options max-old-space-size=32,optimize_for_size --public-packages=prettycron . --output valetudo",
"build": "pkg --targets node14-linux-armv7 --no-bytecode --options expose-gc,max-heap-size=30,optimize-for-size,always-compact,lite-mode --public-packages=prettycron . --output valetudo",
"postbuild": "if [ -d client.b ]; then rm -fr client && mv client.b client; fi"
},
"author": "",
Expand All @@ -34,6 +34,7 @@
"ws": "^7.4.1"
},
"devDependencies": {
"pkg": "4.4.9"
"pkg": "4.4.9",
"cross-env": "7.0.2"
}
}

0 comments on commit f2a0ac1

Please sign in to comment.