Skip to content

Commit

Permalink
Merge pull request #379 from sbs20/staging
Browse files Browse the repository at this point in the history
Docker and documentation
  • Loading branch information
sbs20 authored Dec 20, 2021
2 parents 9d0c0af + 4023b17 commit bdb499f
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 45 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ jobs:
with:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/scanservjs:staging
target: scanservjs-core

- name: Push master
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/scanservjs:latest
target: scanservjs-core

- name: Get version
id: get_version
Expand All @@ -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
72 changes: 45 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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
Expand All @@ -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
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
18 changes: 10 additions & 8 deletions packages/client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ fi
unset IFS
set +f

service dbus start

node ./server/server.js

0 comments on commit bdb499f

Please sign in to comment.