From a6999f03b0d716929f487c3f6a61b17f05da6965 Mon Sep 17 00:00:00 2001 From: sbs20 Date: Mon, 20 Dec 2021 10:53:10 +0000 Subject: [PATCH 1/5] Version update + caniuse --- package-lock.json | 4 ++-- package.json | 2 +- packages/client/package-lock.json | 18 ++++++++++-------- packages/client/package.json | 2 +- packages/server/package-lock.json | 4 ++-- packages/server/package.json | 2 +- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 75f3bc78..6127845f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "scanservjs", - "version": "2.18.1", + "version": "2.19.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "scanservjs", - "version": "2.18.1", + "version": "2.19.0", "hasInstallScript": true, "license": "GPL-2.0" } diff --git a/package.json b/package.json index 9faf4a31..3070b77c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scanservjs", - "version": "2.18.1", + "version": "2.19.0", "description": "scanservjs is a simple web-based UI for SANE which allows you to share a scanner on a network without the need for drivers or complicated installation.", "scripts": { "clean": "rm -rf ./dist", diff --git a/packages/client/package-lock.json b/packages/client/package-lock.json index 69c71bc0..27c19e44 100644 --- a/packages/client/package-lock.json +++ b/packages/client/package-lock.json @@ -1,12 +1,12 @@ { "name": "scanservjs", - "version": "2.18.1", + "version": "2.19.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "scanservjs", - "version": "2.18.1", + "version": "2.19.0", "license": "GPL-2.0", "dependencies": { "@mdi/font": "^5.9.55", @@ -3748,9 +3748,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001228", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001228.tgz", - "integrity": "sha512-QQmLOGJ3DEgokHbMSA8cj2a+geXqmnpyOFT0lhQV6P3/YOJvGDEwoedcwxEQ30gJIwIIunHIicunJ2rzK5gB2A==", + "version": "1.0.30001291", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001291.tgz", + "integrity": "sha512-roMV5V0HNGgJ88s42eE70sstqGW/gwFndosYrikHthw98N5tLnOTxFqMLQjZVRxTWFlJ4rn+MsgXrR7MDPY4jA==", "dev": true, "funding": { "type": "opencollective", @@ -17900,6 +17900,7 @@ "integrity": "sha512-pM7CR3yXB6L8Gfn6EmX7FLNE3+V/15I3o33GkSNsWvgsMp6HVGXKkXgojrcfUUauyL1LZOdvTmu4enU2RePGHw==", "dev": true, "requires": { + "@babel/core": "^7.11.0", "@babel/helper-compilation-targets": "^7.9.6", "@babel/helper-module-imports": "^7.8.3", "@babel/plugin-proposal-class-properties": "^7.8.3", @@ -17912,6 +17913,7 @@ "@vue/babel-plugin-jsx": "^1.0.3", "@vue/babel-preset-jsx": "^1.2.4", "babel-plugin-dynamic-import-node": "^2.3.3", + "core-js": "^3.6.5", "core-js-compat": "^3.6.5", "semver": "^6.1.0" } @@ -19492,9 +19494,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001228", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001228.tgz", - "integrity": "sha512-QQmLOGJ3DEgokHbMSA8cj2a+geXqmnpyOFT0lhQV6P3/YOJvGDEwoedcwxEQ30gJIwIIunHIicunJ2rzK5gB2A==", + "version": "1.0.30001291", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001291.tgz", + "integrity": "sha512-roMV5V0HNGgJ88s42eE70sstqGW/gwFndosYrikHthw98N5tLnOTxFqMLQjZVRxTWFlJ4rn+MsgXrR7MDPY4jA==", "dev": true }, "case-sensitive-paths-webpack-plugin": { diff --git a/packages/client/package.json b/packages/client/package.json index b736d71c..fb0cd6e3 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "scanservjs", - "version": "2.18.1", + "version": "2.19.0", "description": "scanservjs is a simple web-based UI for SANE which allows you to share a scanner on a network without the need for drivers or complicated installation.", "author": "Sam Strachan", "scripts": { diff --git a/packages/server/package-lock.json b/packages/server/package-lock.json index 9b756f48..b998e1ab 100644 --- a/packages/server/package-lock.json +++ b/packages/server/package-lock.json @@ -1,12 +1,12 @@ { "name": "scanservjs-server", - "version": "2.18.1", + "version": "2.19.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "scanservjs-server", - "version": "2.18.1", + "version": "2.19.0", "license": "GPL-2.0", "dependencies": { "adm-zip": "^0.5.5", diff --git a/packages/server/package.json b/packages/server/package.json index 785cb8ac..875267c5 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,6 +1,6 @@ { "name": "scanservjs-server", - "version": "2.18.1", + "version": "2.19.0", "description": "scanservjs is a simple web-based UI for SANE which allows you to share a scanner on a network without the need for drivers or complicated installation.", "scripts": { "lint": "gulp lint", From 01b6940f2669b07d887a44ef2e92e2b2b081f63f Mon Sep 17 00:00:00 2001 From: sbs20 Date: Mon, 20 Dec 2021 11:24:52 +0000 Subject: [PATCH 2/5] Dockerfile #377 --- .github/workflows/docker.yml | 3 ++ Dockerfile | 72 ++++++++++++++++++++++-------------- docs/development.md | 12 +++++- packages/server/installer.sh | 2 +- 4 files changed, 59 insertions(+), 30 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 05fb826c..8ce9e47b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -34,6 +34,7 @@ jobs: with: push: true tags: ${{ secrets.DOCKERHUB_USERNAME }}/scanservjs:staging + target: scanservjs-core - name: Push master if: github.ref == 'refs/heads/master' @@ -41,6 +42,7 @@ jobs: with: push: true tags: ${{ secrets.DOCKERHUB_USERNAME }}/scanservjs:latest + target: scanservjs-core - name: Get version id: get_version @@ -53,3 +55,4 @@ jobs: with: push: ${{ github.event_name != 'pull_request' }} tags: ${{ secrets.DOCKERHUB_USERNAME }}/scanservjs:release-${{ steps.get_version.outputs.VERSION }} + target: scanservjs-core diff --git a/Dockerfile b/Dockerfile index 3e681463..69607b4a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ -# Builder image. -FROM node:14-alpine AS builder +# Builder image +# +# The builder image simply builds the core javascript app and nothing else +# ============================================================================== +FROM node:16-alpine AS scanservjs-build ENV APP_DIR=/app WORKDIR "$APP_DIR" @@ -14,42 +17,36 @@ COPY packages/server/ "$APP_DIR/packages/server/" RUN npm run build -# production image -FROM node:14-buster-slim - -# Make it possible to override the UID/GID/username of the user running scanservjs -ARG UID=2001 -ARG GID=2001 -ARG UNAME=scanservjs - -ENV APP_DIR=/app -WORKDIR "$APP_DIR" +# Sane image +# +# This is the minimum bullseye/node/sane image required which is used elsewhere. +# ============================================================================== +FROM node:16-bullseye-slim AS scanservjs-base RUN apt-get update \ - && apt-get install -yq curl gpg \ - && echo 'deb http://download.opensuse.org/repositories/home:/pzz/Debian_10/ /' \ - | tee /etc/apt/sources.list.d/home:pzz.list \ - && curl -fsSL https://download.opensuse.org/repositories/home:pzz/Debian_10/Release.key \ - | gpg --dearmor \ - | tee /etc/apt/trusted.gpg.d/home:pzz.gpg \ - > /dev/null \ - && apt-get update \ && apt-get install -yq \ imagemagick \ sane \ sane-utils \ - sane-airscan \ tesseract-ocr \ + sane-airscan \ && sed -i \ 's/policy domain="coder" rights="none" pattern="PDF"/policy domain="coder" rights="read | write" pattern="PDF"'/ \ /etc/ImageMagick-6/policy.xml \ && sed -i \ 's/policy domain="resource" name="disk" value="1GiB"/policy domain="resource" name="disk" value="8GiB"'/ \ /etc/ImageMagick-6/policy.xml \ - && npm install -g npm@7.11.2 + && npm install -g npm@8.3.0 -# Create a known user -RUN groupadd -g $GID -o $UNAME -RUN useradd -o -u $UID -g $GID -m -s /bin/bash $UNAME +# Core image +# +# This is the minimum core image required. It installs the base dependencies for +# sane and tesseract. The executing user remains ROOT. If you want to build your +# own image with drivers then this is likely the image to start from. +# ============================================================================== +FROM scanservjs-base AS scanservjs-core + +ENV APP_DIR=/app +WORKDIR "$APP_DIR" ENV \ # This goes into /etc/sane.d/net.conf @@ -69,11 +66,32 @@ RUN ["chmod", "+x", "/run.sh"] ENTRYPOINT [ "/run.sh" ] # Copy the code and install -COPY --from=builder "$APP_DIR/dist" "$APP_DIR/" +COPY --from=scanservjs-build "$APP_DIR/dist" "$APP_DIR/" RUN npm install --production +EXPOSE 8080 + +# User2001 image +# +# This image changes the executing user to 2001 for increased security. This +# also, however, leads to some runtime issues with parameters. This was the +# default behaviour from v2.9.0 until v2.18.1 and was because issue #177. This +# stage is kept for backwards compatibility. +# ============================================================================== +FROM scanservjs-core AS scanservjs-user2001 + +# Make it possible to override the UID/GID/username of the user running scanservjs +ARG UID=2001 +ARG GID=2001 +ARG UNAME=scanservjs + +# Create a known user +RUN groupadd -g $GID -o $UNAME +RUN useradd -o -u $UID -g $GID -m -s /bin/bash $UNAME + # Change the ownership of config and data since we need to write there RUN chown -R $UID:$GID config data /etc/sane.d/net.conf /etc/sane.d/airscan.conf USER $UNAME -EXPOSE 8080 +# default build +FROM scanservjs-core diff --git a/docs/development.md b/docs/development.md index b9622882..28d2c772 100644 --- a/docs/development.md +++ b/docs/development.md @@ -7,7 +7,7 @@ sudo apt-get install curl nodejs npm imagemagick sane-utils tesseract-ocr # Ideally set the npm version -sudo npm install npm@7.11.2 -g +sudo npm install npm@8.3.0 -g # Enable PDF (required for execution and unit tests) sudo sed -i 's/policy domain="coder" rights="none" pattern="PDF"/policy domain="coder" rights="read | write" pattern="PDF"'/ /etc/ImageMagick-6/policy.xml @@ -83,9 +83,17 @@ sudo chmod 666 /var/run/docker.sock Useful commands ```sh -# Build and run +# Build docker build -t scanservjs-image . + +# Build the core image +docker build --target scanservjs-core -t scanservjs-image . + +# Remove any existing containers docker rm --force scanservjs-container 2> /dev/null + +# Different run options +docker run -d -p 8080:8080 --name scanservjs-container --privileged scanservjs-image docker run -d -p 8080:8080 -v /var/run/dbus:/var/run/dbus --name scanservjs-container --privileged scanservjs-image docker run -d -p 8080:8080 -v $HOME/scan-data:/app/data/output --name scanservjs-container --privileged scanservjs-image diff --git a/packages/server/installer.sh b/packages/server/installer.sh index bd255405..47a7c046 100644 --- a/packages/server/installer.sh +++ b/packages/server/installer.sh @@ -25,7 +25,7 @@ install() { sane-utils \ tesseract-ocr - npm install npm@7.11.2 -g + npm install npm@8.3.0 -g if [ -d "$location" ]; then # keep config and data From 140181af1e86595bf5cb95b1a060b66cf39517b5 Mon Sep 17 00:00:00 2001 From: sbs20 Date: Mon, 20 Dec 2021 11:25:17 +0000 Subject: [PATCH 3/5] service dbus start #352 --- run.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/run.sh b/run.sh index f9b1647a..c611248b 100644 --- a/run.sh +++ b/run.sh @@ -33,5 +33,7 @@ fi unset IFS set +f +service dbus start + node ./server/server.js From 5addb5f4ecf20009ae323ea9d64875a1c1eddeef Mon Sep 17 00:00:00 2001 From: sbs20 Date: Mon, 20 Dec 2021 11:50:15 +0000 Subject: [PATCH 4/5] readme.md --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/README.md b/README.md index 9788d541..0058798d 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,56 @@ It supports any * [Configuration and device override](docs/config.md) * [Integration](docs/integration.md) +## Running scanservjs + +In most cases the use of the app should be fairly self-explanatory. When the app +first loads, it attempts to detect your scanner - this step is the most +precarious and may either require custom drivers or some additional steps if +you're running a network scanner or docker. See the documentation above for +more. + +Once the scanner is detected then you have a number of pages. + +### Scan: + +This page gives access to the controls for your scanner. The app will generally +find the settings available automatically, although some scanners mis-report +their abilities. (If this is the case, then you can override what's detected, +see [Configuration and device override](docs/config.md) for more). If geometry +is available (selecting scan size and position) then you will have cropping +available to you. + +There is also the ability to perform batch scanning. If you have a document +feeder, then just use the `Auto` option. If not then use `Manual` and the app +will prompt you to change pages between scans. + +Any scan operation will always result in a single file. Some image formats, such +as PDF and TIF support multiple pages, while others, such as PNG and JPG do not. +If the scan pipeline results in more than one file, then the app will zip the +files into a single output. You can choose the image format under `Format`. + +You can create and customise your own pipelines. + +### Files + +Any scanned files will be saved in a flat directory which has a simple web view +available on this page. The intended usage of the app is to allow the user to +save their scans locally - i.e. to download the files. The app will never delete +these files, but if you run under docker then unless volume mapping is specified +then the files may be lost when you run a new version. + +Furthermore, users in real life will want to store their scans with their own +names, directory structures and cloud services or NAS devices. The permutations +and possibilities are endless and are beyond the scope of the app. + +### Settings + +The settings page allows you to change the appearance and locale / language. + +### About + +Copyright information and system info. + ## Why? This is yet another scanimage-web-front-end. Why? It originally started as an From 1b45d147b99cd1ab5dc915bc0cb2e690abce1425 Mon Sep 17 00:00:00 2001 From: sbs20 Date: Mon, 20 Dec 2021 12:16:08 +0000 Subject: [PATCH 5/5] readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0058798d..24e9ade0 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ more. Once the scanner is detected then you have a number of pages. -### Scan: +### Scan This page gives access to the controls for your scanner. The app will generally find the settings available automatically, although some scanners mis-report