Skip to content

Commit

Permalink
Merge pull request #122 from sbs20/staging
Browse files Browse the repository at this point in the history
Staging v2.5.0
  • Loading branch information
sbs20 authored Jan 31, 2021
2 parents f9f2639 + 490e575 commit 10330ab
Show file tree
Hide file tree
Showing 87 changed files with 12,062 additions and 6,936 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
server/node_modules
webui/node_modules
13 changes: 6 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Node.js CI
name: NodeCI

on:
workflow_dispatch:
Expand Down Expand Up @@ -40,14 +40,13 @@ jobs:
- run: sudo sed -i 's/policy domain="coder" rights="none" pattern="PDF"/policy domain="coder" rights="read | write" pattern="PDF"'/ /etc/ImageMagick-6/policy.xml

# Install packages and build
- run: npm install
- run: npm run server-lint
- run: npm run server-build
- run: npm run client-build
- run: npm run test
- run: cd server && npm i --loglevel=error && cd ../webui && npm i --loglevel=error
- run: cd server && npm run server-lint
- run: cd server && npm run test
- run: cd webui && npm run build && cd ../server && npm run server-build
env:
CI: true
- run: npm run package
- run: cd server && npm run package

# We may need the package name for a release later (if not the dev branch and it's node 12)
- name: Retrieve package name
Expand Down
14 changes: 6 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,17 @@ $RECYCLE.BIN/
*.lnk

# Release folders
release/**/*
dist/**/*
release
dist

# VSCode
.vscode


# Project specific
*.tif
*.pdf
*.png
data/output/*
data/temp/*
server/config/devices.json
server/data/output/*
server/data/temp/*
server/data/preview/*.tif
scan*.jpg
config/devices.json
var
43 changes: 30 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
# builder image
# Builder image. Alpine doesn't have python which is required by node-sass
FROM node:buster AS builder
ENV APP_DIR=/app
WORKDIR "$APP_DIR"
COPY package*.json "$APP_DIR/"
RUN npm install
COPY . "$APP_DIR"
RUN npm run server-build && npm run client-build

COPY server/package*.json "$APP_DIR/server/"
COPY webui/package*.json "$APP_DIR/webui/"

RUN cd server \
&& npm i --loglevel=error \
&& cd ../webui \
&& npm i --loglevel=error

COPY webui/ "$APP_DIR/webui/"
COPY server/ "$APP_DIR/server/"

RUN cd webui \
&& npm run build \
&& cd ../server \
&& npm run server-build

# production image
FROM node:buster-slim
ENV APP_DIR=/app
WORKDIR "$APP_DIR"
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 sane sane-utils imagemagick 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
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 \
&& sed -i 's/policy domain="coder" rights="none" pattern="PDF"/policy domain="coder" rights="read | write" pattern="PDF"'/ /etc/ImageMagick-6/policy.xml

COPY --from=builder "$APP_DIR/dist" "$APP_DIR/"

Expand All @@ -32,7 +49,7 @@ ENV AIRSCAN_DEVICES=""
# This directs scanserv not to bother querying `scanimage -L`
ENV SCANIMAGE_LIST_IGNORE=""

# This gets added to scanservjs/config/config.js:devices
# This gets added to scanservjs/server/config.js:devices
ENV DEVICES=""

# Override OCR language
Expand Down
94 changes: 70 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,59 @@
# scanservjs
scanservjs is a simple web-based UI for your scanner. It allows you to share one
or more scanners (using SANE) on a network without the need for drivers or
complicated installation. It can save to TIF, JPG, PNG, PDF and TXT (with
Tesseract OCR) with varying compression settings, all of which can configured.
It supports multipage scanning and all

[![Build Status](https://github.com/sbs20/scanservjs/workflows/NodeCI/badge.svg)](https://github.com/sbs20/scanservjs/actions)
[![Code QL Status](https://github.com/sbs20/scanservjs/workflows/CodeQL/badge.svg)](https://github.com/sbs20/scanservjs/actions)
[![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/sbs20/scanservjs)](https://hub.docker.com/r/sbs20/scanservjs)
[![Docker Pulls](https://img.shields.io/docker/pulls/sbs20/scanservjs)](https://hub.docker.com/r/sbs20/scanservjs)
[![GitHub stars](https://img.shields.io/github/stars/sbs20/scanservjs?label=Github%20stars)](https://github.com/sbs20/scanservjs)
[![GitHub watchers](https://img.shields.io/github/watchers/sbs20/scanservjs?label=Github%20Watchers)](https://github.com/sbs20/scanservjs)
[![Docker Stars](https://img.shields.io/docker/stars/sbs20/scanservjs)](https://hub.docker.com/r/sbs20/scanservjs)
[![GitHub](https://img.shields.io/github/license/sbs20/scanservjs)](https://github.com/sbs20/scanservjs/blob/master/LICENSE.md)


scanservjs is a web-based UI for your scanner. It allows you to share one or
more scanners (using SANE) on a network without the need for drivers or
complicated installation. It enables easy cropping, sources, resolution, output
formats (TIF, JPG, PNG, PDF and TXT with Tesseract OCR) with varying compression
settings, all of which can be configured. It supports multipage scanning and all
[SANE compatible devices](http://www.sane-project.org/sane-supported-devices.html).

![screenshot](https://github.com/sbs20/scanservjs/raw/master/docs/screen0.png)

Copyright 2016-2020 [Sam Strachan](https://github.com/sbs20)
Copyright 2016-2021 [Sam Strachan](https://github.com/sbs20)

## Requirements
* SANE
* ImageMagick
* Tesseract (optional)
* nodejs
* SANE Scanner
* Linux host (or VM with necessary pass-through e.g. USB)
* Software sane-utils, ImageMagick, Tesseract (optional) and nodejs

## Installation notes
For an easy docker-based install (assuming that SANE supports your scanner
out-of-the-box on Debian) use the following commands. Please note that by
default, configuration and scanned images are stored within the container and
will be lost if you recreate it. If you want to map your scanned images then
specify the volume mapping option `-v /local/path/:/app/data/output/`

**Please note that the docker image is amd64 only - and will not work on ARM
devices such as the Raspberry Pi. Please follow the manual installation process
in these cases**
out-of-the-box on Debian) use the following commands:

```console
docker pull sbs20/scanservjs:latest
docker rm --force scanservjs-container 2> /dev/null
docker run -d -p 8080:8080 -v /var/run/dbus:/var/run/dbus --restart unless-stopped --name scanservjs-container --privileged sbs20/scanservjs:latest
```
(`--privileged` is required for the container to access the host's devices, to
allow it to talk to the scanner)

scanservjs will now be accessible from `http://$host:8080/`

* ⚠ By default, configuration and scanned images are stored within the container
and will be lost if you recreate it. If you want to map your scanned images
then specify the volume mapping option `-v /local/path/:/app/data/output/`
* ⚠ The docker image is amd64 only - and will not work on ARM devices such as
the Raspberry Pi. Please follow the manual installation process in these
cases
*`--privileged` is required for the container to access the host's devices,
to allow it to talk to the scanner. The best way to do this is to map the
actual USB ports. Run `sudo sane-find-scanner -q` and you will get a result
like
`found USB scanner (vendor=0x04a9 [Canon], product=0x220d [CanoScan], chip=LM9832/3) at libusb:001:003`.
This translates to `/dev/bus/usb/001/003`. In turn the docker argument would
be `--device=/dev/bus/usb/001/003:/dev/bus/usb/001/003`. However, oftentimes,
there are [reports](#66) that devices change address across reboots which
complicates matters.

If you want to install the latest staging branch (this may contain newer code)

```console
Expand Down Expand Up @@ -66,6 +83,34 @@ More installation options:
* `DEVICES`: Force add devices use `DEVICES` (semicolon delimited)
* `SCANIMAGE_LIST_IGNORE`: To force ignore `scanimage -L`

## Configuration override
If you want to override some specific configuration setting then you can do so
within `./config/config.local.js`. Using docker you will need to map the volume
using `-v /my/local/path/:/app/config/` then create a file in your directory
called `config.local.js`. See [example source](./server/config/config.local.js)
for more options.

```javascript
module.exports = {
afterConfig(config) {
// Set default preview resolution
config.previewResolution = 300;

// Add a custom print pipeline
config.pipelines.push({
extension: 'pdf',
description: 'Print PDF',
commands: [
'convert @- -quality 92 tmp-%04d.jpg && ls tmp-*.jpg',
'convert @- scan-0000.pdf',
'lp -d MY_PRINTER scan-0000.pdf',
'ls scan-*.*'
]
});
}
};
```

## Airscan
[sane-airscan](https://github.com/alexpevzner/sane-airscan) uses Avahi /
Zeroconf / Bonjour to discover devices on the local network. If you are running
Expand All @@ -89,7 +134,7 @@ use `scanimage -L`, force a list of devices and override the OCR language

```console
docker run -d -p 8080:8080 \
-e SANED_HOSTS="10.0.100.30;10.0.100.31" \
-e SANED_NET_HOSTS="10.0.100.30;10.0.100.31" \
-e AIRSCAN_DEVICES='"Canon MFD" = "http://192.168.0.10/eSCL";"EPSON MFD" = "http://192.168.0.11/eSCL"' \
-e SCANIMAGE_LIST_IGNORE=true \
-e DEVICES="net:10.0.100.30:plustek:libusb:001:003;net:10.0.100.31:plustek:libusb:001:003;airscan:e0:Canon TR8500 series;airscan:e1:EPSON Cool Series" \
Expand All @@ -103,11 +148,12 @@ This is yet another scanimage-web-front-end. Why? It originally started as an
adaptation of phpsane - just to make everything a bit newer, give it a refresh
and make it work on minimal installations without imagemagick - that version is
[still available](https://github.com/sbs20/scanserv) but is no longer
maintained. Then, I just wanted to write it in node and enhance it a bit, and
it's been a labour of love ever since.
maintained. Since then, I just wanted to write it in node and enhance it a bit,
and it's been a labour of love ever since.

## Acknowledgements
* This project owes a lot to [phpsane](http://sourceforge.net/projects/phpsane/)
* This project owes its genesis to
[phpsane](http://sourceforge.net/projects/phpsane/)

## More about SANE
* http://www.sane-project.org/
113 changes: 0 additions & 113 deletions client/App.vue

This file was deleted.

1 change: 0 additions & 1 deletion client/assets/autorenew-24px.svg

This file was deleted.

1 change: 0 additions & 1 deletion client/assets/delete-24px.svg

This file was deleted.

1 change: 0 additions & 1 deletion client/assets/photo_camera-24px.svg

This file was deleted.

1 change: 0 additions & 1 deletion client/assets/refresh-24px.svg

This file was deleted.

1 change: 0 additions & 1 deletion client/assets/search-24px.svg

This file was deleted.

Loading

0 comments on commit 10330ab

Please sign in to comment.