Skip to content

Commit

Permalink
Merge pull request #90 from sbs20/staging
Browse files Browse the repository at this point in the history
v2.1.0
  • Loading branch information
sbs20 authored Oct 16, 2020
2 parents e656031 + d5ebc7b commit 6378858
Show file tree
Hide file tree
Showing 38 changed files with 1,654 additions and 555 deletions.
File renamed without changes.
63 changes: 60 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,82 @@
name: Node.js CI

#on: [push]
on: [workflow_dispatch]
on:
workflow_dispatch:
push:
branches:
- development
- staging
- master

jobs:
build:
runs-on: ubuntu-latest

strategy:
max-parallel: 6
matrix:
node-version: [8.x, 10.x, 12.x]
node-version: [10.x, 12.x]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

# Use nodejs cache
- name: Cache Node.js modules
uses: actions/cache@v2
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
# Enable conversion to PDF
- 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
env:
CI: true
- run: 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
if: endsWith(matrix.node-version, '12.x') && !endsWith(github.ref, 'development')
run: |
echo "PACKAGE_NAME=$(ls ./release/)" >> $GITHUB_ENV
# Create a draft release if there's a package
- name: Create Release
id: create_release
if: env.PACKAGE_NAME
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: true

# Upload the release package
- name: Upload Release Asset
id: upload-release-asset
if: env.PACKAGE_NAME
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./release/${{ env.PACKAGE_NAME }}
asset_name: ${{ env.PACKAGE_NAME }}
asset_content_type: application/gzip
10 changes: 5 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ name: "CodeQL"

on:
push:
branches: [master]
branches: [master, staging]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
# schedule:
# - cron: '0 7 * * 2'
branches: [master, staging]
workflow_dispatch:

#schedule:
# - cron: '0 7 * * 2'

jobs:
analyze:
name: Analyze
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ dist/**/*
*.tif
*.pdf
*.png
data/output/*.txt
data/output/*
data/temp/*
scan*.jpg
config/devices.json
var
30 changes: 23 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,38 @@ WORKDIR "$APP_DIR"
COPY package*.json "$APP_DIR/"
RUN npm install
COPY . "$APP_DIR"
RUN npm run server-build
RUN npm run client-build
RUN npm run server-build && npm run client-build

# production image
FROM node:buster-slim
ENV APP_DIR=/app
WORKDIR "$APP_DIR"
# Install sane
RUN apt-get update && apt-get install -yq sane sane-utils imagemagick
RUN 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 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

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

# Install dependencies
RUN npm install --production

ENV NET_HOST=""
# This goes into /etc/sane.d/net.conf
ENV SANED_NET_HOSTS=""

# This gets added to /etc/sane.d/airscan.conf
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
ENV DEVICES=""

# Override OCR language
ENV OCR_LANG=""

# Copy entry point
COPY run.sh /run.sh
Expand Down
63 changes: 57 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# scanservjs
scanservjs is a simple web-based UI for your scanner. It allows you to share a
scanner (using SANE) on a network without the need for drivers or complicated
installation. It can save to TIF, JPG, PNG and PDF with varying compression
settings, all of which can configured. It supports all
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
[SANE compatible devices](http://www.sane-project.org/sane-supported-devices.html).

![screenshot](https://github.com/sbs20/scanservjs/raw/master/docs/screen0.png)
Expand All @@ -12,6 +13,7 @@ Copyright 2016-2020 [Sam Strachan](https://github.com/sbs20)
## Requirements
* SANE
* ImageMagick
* Tesseract (optional)
* nodejs

## Installation notes
Expand All @@ -21,10 +23,14 @@ 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**

```console
docker pull sbs20/scanservjs:latest
docker rm --force scanservjs-container 2> /dev/null
docker run -d -p 8080:8080 --restart unless-stopped --name scanservjs-container --privileged sbs20/scanservjs:latest
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)
Expand All @@ -36,7 +42,7 @@ If you want to install the latest staging branch (this may contain newer code)
```console
docker pull sbs20/scanservjs:staging
docker rm --force scanservjs-container 2> /dev/null
docker run -d -p 8080:8080 --restart unless-stopped --name scanservjs-container --privileged sbs20/scanservjs:staging
docker run -d -p 8080:8080 -v /var/run/dbus:/var/run/dbus --restart unless-stopped --name scanservjs-container --privileged sbs20/scanservjs:staging
```

More installation options:
Expand All @@ -45,6 +51,51 @@ More installation options:
* [Development notes](docs/development.md)
* [Configuring the scanner and SANE](docs/sane.md)

## Environment variables

* `SANED_NET_HOSTS`: If you want to use a
[SaneOverNetwork](https://wiki.debian.org/SaneOverNetwork#Server_Configuration)
scanner then to perform the equivalent of adding hosts to
`/etc/sane.d/net.conf` specify a list of ip addresses separated by semicolons
in the `SANED_NET_HOSTS` environment variable.
* `AIRSCAN_DEVICES`: If you want to specifically add `sane-airscan` devices to
your `/etc/sane.d/airscan.conf` then use the `AIRSCAN_DEVICES` environment
variable (semicolon delimited).
* `DEVICES`: Force add devices use `DEVICES` (semicolon delimited)
* `SCANIMAGE_LIST_IGNORE`: To force ignore `scanimage -L`

## Airscan
[sane-airscan](https://github.com/alexpevzner/sane-airscan) uses Avahi /
Zeroconf / Bonjour to discover devices on the local network. If you are running
docker you will want to share dbus to make it work
(`-v /var/run/dbus:/var/run/dbus`).

## Example docker run

### Use airscan and a locally detected scanner
This should support most use cases

```console
docker run -d -p 8080:8080 \
-v /var/run/dbus:/var/run/dbus \
--name scanservjs-container --privileged scanservjs-image
```

### Complicated
Add two net hosts to sane, use airscan to connect to two remote scanners, don't
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 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" \
-e OCR_LANG="fra" \
-v /var/run/dbus:/var/run/dbus \
--name scanservjs-container --privileged scanservjs-image
```

## Why?
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
Expand Down
Loading

0 comments on commit 6378858

Please sign in to comment.