Skip to content

Commit

Permalink
Merge pull request #291 from sbs20/staging
Browse files Browse the repository at this point in the history
Docker build / device discovery / i18n
  • Loading branch information
sbs20 authored May 31, 2021
2 parents b5fbc8c + c3c584f commit acd53c9
Show file tree
Hide file tree
Showing 21 changed files with 199 additions and 75 deletions.
17 changes: 12 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ COPY package*.json "$APP_DIR/"
COPY packages/server/package*.json "$APP_DIR/packages/server/"
COPY packages/client/package*.json "$APP_DIR/packages/client/"

RUN npm run docker-install
RUN npm run install

COPY packages/client/ "$APP_DIR/packages/client/"
COPY packages/server/ "$APP_DIR/packages/server/"

RUN npm run docker-build
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"
RUN apt-get update \
Expand All @@ -39,7 +45,8 @@ RUN apt-get update \
&& npm install -g [email protected]

# Create a known user
RUN useradd -u 2001 -ms /bin/bash scanservjs
RUN groupadd -g $GID -o $UNAME
RUN useradd -o -u $UID -g $GID -m -s /bin/bash $UNAME

ENV \
# This goes into /etc/sane.d/net.conf
Expand All @@ -63,7 +70,7 @@ COPY --from=builder "$APP_DIR/dist" "$APP_DIR/"
RUN npm install --production

# Change the ownership of config and data since we need to write there
RUN chown -R scanservjs:scanservjs config data /etc/sane.d/net.conf /etc/sane.d/airscan.conf
USER scanservjs
RUN chown -R $UID:$GID config data /etc/sane.d/net.conf /etc/sane.d/airscan.conf
USER $UNAME

EXPOSE 8080
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Copyright 2016-2021 [Sam Strachan](https://github.com/sbs20)
> an awesome web interface makes it even more brilliant!

> This is a great project! The touchscreen and buttons on my Brother scanner are
> broken, meaning the device is useless by itself because one cannot trigger
> scans, but with this project I can trigger it remotely just fine.
## About

scanservjs is a web UI frontend for your scanner. It allows you to share one or
Expand Down
32 changes: 19 additions & 13 deletions docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,33 @@ Depending on your setup you have a number of options.

## Mapping volumes

There are two volumes you may wish to map:
To access data from outside the docker container, there are two volumes you may
wish to map:

* The scanned images: use `-v /local/path/scans:/app/data/output`
* Configuration overrides: use `-v /local/path/cfg:/app/config`

## User and group mapping
### User and group mapping

The docker image which is created now runs under a non-privileged user account
with a UID of `2001`. If you attempt to run as a user other than `2001` or `0`
(e.g. `-u 1000`) then the process inside the container will no longer have
access to some of the things it needs to and it will fail. Most of the time you
won't care about the user, but if you're mapping volumes for either config or
data, then it may matter.
When mapping volumes, special attention must be paid to users and file systems
permissions.

The solution in most cases is either to
* change the group of the container to a known group on the host e.g.
The docker container runs under a non-privileged user with a UID and GID of `2001`.
scanservjs relies on this user for editing SANE and airscan configurations inside
the container. Changing this user's UID (e.g. by using `-u 1000` for `docker run`)
to access scans/configuration from outside docker **is not advised since it will
cause these steps to fail.**

Your alternatives are:
1. changing the group of the container to a known group on the host e.g.
`-u 2001:1000`. This will keep the user correct (`2001`) but change the group
(`1000`)
* create a corresponding user on the host e.g.
(`1000`).
2. creating a corresponding user on the host e.g.
`useradd -u 2001 -ms /bin/bash scanservjs`
* change the host volume permissions e.g. `chmod 777 local-volume`
3. building a docker image with a custom UID/GID pairing: clone this repository
and run `docker build --build-arg UID=1234 --build-arg GID=5678 -t scanservjs_custom .`
(with UID and GID adjusted to your liking), then run the custom image (e.g. `docker run scanservjs_custom`).
4. as a last resort, changing the host volume permissions e.g. `chmod 777 local-volume`

## Environment variables

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.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scanservjs",
"version": "2.15.0",
"version": "2.15.1",
"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 All @@ -10,9 +10,8 @@
"test": "cd packages/server && npm run test",
"build": "npm run clean && cd packages/client && npm run build && cd ../server && npm run build",
"package": "cd packages/server && npm run package",
"docker-install": "npm run install",
"docker-build": "npm run build",
"verify": "npm run version && npm run lint && npm run test",
"docker-build": "npm run verify && docker build -t scanservjs-image .",
"release": "npm run verify && npm run build && npm run package",
"serve": "cd packages/client && npm run serve"
},
Expand Down
4 changes: 2 additions & 2 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.15.0",
"version": "2.15.1",
"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
1 change: 1 addition & 0 deletions packages/client/src/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"left-aligned": "zarovnáno vlevo",
"centrally-aligned": "zarovnáno na střed",
"duplex": "oboustranně",
"transparency unit": "Transparency Unit",

"automatic document feeder": "@:source.adf",
"automatic document feeder(left aligned)": "@:source.adf (@:source.left-aligned)",
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"left-aligned": "Left Aligned",
"centrally-aligned": "Centrally Aligned",
"duplex": "Duplex",
"transparency unit": "Transparency Unit",

"automatic document feeder": "@:source.adf",
"automatic document feeder(left aligned)": "@:source.adf (@:source.left-aligned)",
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"left-aligned": "Left Aligned",
"centrally-aligned": "Centrally Aligned",
"duplex": "Duplex",
"transparency unit": "Transparency Unit",

"automatic document feeder": "@:source.adf",
"automatic document feeder(left aligned)": "@:source.adf (@:source.left-aligned)",
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"left-aligned": "Alineado a la izquierda",
"centrally-aligned": "Alineado al centro",
"duplex": "Dúplex",
"transparency unit": "Transparency Unit",

"automatic document feeder": "@:source.adf",
"automatic document feeder(left aligned)": "@:source.adf (@:source.left-aligned)",
Expand Down
85 changes: 43 additions & 42 deletions packages/client/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@
},

"colors": {
"accent-4": "Default",
"red": "Red",
"pink": "Pink",
"purple": "Purple",
"deep-purple": "Deep purple",
"accent-4": "Défaut",
"red": "Rouge",
"pink": "Rose",
"purple": "Violet",
"deep-purple": "Violet foncé",
"indigo": "Indigo",
"blue": "Blue",
"light-blue": "Light blue",
"blue": "Bleu",
"light-blue": "Bleu clair",
"cyan": "Cyan",
"teal": "Teal",
"green": "Green",
"light-green": "Light green",
"lime": "Lime",
"yellow": "Yellow",
"amber": "Amber",
"teal": "Sarcelle",
"green": "Vert",
"light-green": "Vert clair",
"lime": "Vert citron",
"yellow": "Jaune",
"amber": "Ambre",
"orange": "Orange",
"deep-orange": "Deep orange",
"brown": "Brown",
"blue-grey": "Blue grey",
"grey": "Grey"
"deep-orange": "Orange foncé",
"brown": "Brun",
"blue-grey": "Bleu gris",
"grey": "Gris"
},

"batch-dialog": {
Expand Down Expand Up @@ -69,9 +69,9 @@
},

"mode": {
"color": "Colour",
"halftone": "Halftone",
"gray": "Grey",
"color": "Couleur",
"halftone": "Noir et blanc",
"gray": "Niveau de gris",
"lineart": "Lineart",

"24bitcolor":"@:mode.color",
Expand All @@ -82,12 +82,13 @@
},

"source": {
"flatbed": "Flatbed",
"adf": "Automatic Document Feeder",
"flatbed": "Vitre du scanner",
"adf": "ADF",
"auto": "Auto",
"left-aligned": "Left Aligned",
"centrally-aligned": "Centrally Aligned",
"left-aligned": "Aligné à gauche",
"centrally-aligned": "Aligné centré",
"duplex": "Duplex",
"transparency unit": "Transparency Unit",

"automatic document feeder": "@:source.adf",
"automatic document feeder(left aligned)": "@:source.adf (@:source.left-aligned)",
Expand All @@ -97,24 +98,24 @@
},

"pipeline": {
"high-quality": "Qualité élevée",
"high-quality": "Qualité haute",
"medium-quality": "Qualité moyenne",
"low-quality": "Qualité basse",
"uncompressed": "Décompressé",
"lzw-compressed": "Compression LZW",
"lzw-compressed": "Compressé LZW",
"ocr": "OCR",
"text-file": "Fichier texte"
},

"scan": {
"device": "Appareil",
"device": "Scanner",
"source": "Source",
"resolution": "Résolution",
"mode": "Mode",
"dynamic-lineart": "Dynamic Lineart",
"dynamic-lineart:enabled": "Activé",
"dynamic-lineart:disabled": "Désactivé",
"batch": "Scan groupé",
"batch": "Batch",
"filters": "Filtres",
"format": "Format",
"btn-preview": "Aperçu",
Expand All @@ -124,32 +125,32 @@
"left": "Gauche",
"width": "Largeur",
"height": "Hauteur",
"paperSize": "Paper size",
"paperSize": "Taille papier",
"brightness": "Luminosité",
"contrast": "Contraste",
"message:loading-devices": "Chargement des scanners...",
"message:no-devices": "Aucun scanner trouvé",
"message:deleted-preview": "Prévisualisation effacée",
"message:turn-documents": "Tournez votre document",
"message:preview-of-page": "Prévisualisation de la page"
"message:deleted-preview": "Aperçu supprimé",
"message:turn-documents": "Tourner le document",
"message:preview-of-page": "Aperçu de la page"
},

"settings": {
"title": "@:navigation.settings",
"behaviour-ui": "Comportement et interface utilisateur",
"behaviour-ui": "Paramètres et interface utilisateur",
"locale": "Langue",
"locale:description": "Sélection de la langue",
"locale:description": "Choisir la langue de l'application",
"theme": "Thème",
"theme:description": "Theme. Si vous utilisez le thème de votre système d'exploitation et que vous changez le paramètre, vous devrez recharger l'application",
"theme:system": "Système",
"theme:light": "Clair",
"theme:dark": "Sombre",
"color": "Colour",
"color:description": "Colour. This will change the colour of the top app bar.",
"devices": "Devices and storage",
"reset:description": "Clears stored scanner devices and forces a reload",
"reset": "Réinitialiser",
"clear-storage:description": "Clears local storage of any cached parameters",
"clear-storage": "Clear"
"theme:dark": "Foncé",
"color": "Couleur",
"color:description": "Couleur. Ce paramètre modifie la couleur de la barre supérieure",
"devices": "Scanners et mémoire locale de l'application",
"reset:description": "Efface les scanners mémorisés et force une recherche d'appareils",
"reset": "Ré-initialiser",
"clear-storage:description": "Efface les données locales des paramètres en cache",
"clear-storage": "Effacer"
}
}
1 change: 1 addition & 0 deletions packages/client/src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"left-aligned": "Allineato a sinistra",
"centrally-aligned": "Allineato al centro",
"duplex": "Fronte/retro",
"transparency unit": "Adattatore per trasparenza",

"automatic document feeder": "@:source.adf",
"automatic document feeder(left aligned)": "@:source.adf (@:source.left-aligned)",
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/locales/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"left-aligned": "Left Aligned",
"centrally-aligned": "Centrally Aligned",
"duplex": "Duplex",
"transparency unit": "Transparency Unit",

"automatic document feeder": "@:source.adf",
"automatic document feeder(left aligned)": "@:source.adf (@:source.left-aligned)",
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"left-aligned": "Left Aligned",
"centrally-aligned": "Centrally Aligned",
"duplex": "Duplex",
"transparency unit": "Transparency Unit",

"automatic document feeder": "@:source.adf",
"automatic document feeder(left aligned)": "@:source.adf (@:source.left-aligned)",
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/locales/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"left-aligned": "##LEFT",
"centrally-aligned": "##CENTRAL",
"duplex": "##DUPLEX",
"transparency unit": "##TRANSPARENCY",

"automatic document feeder": "@:source.adf",
"automatic document feeder(left aligned)": "@:source.adf (@:source.left-aligned)",
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.15.0",
"version": "2.15.1",
"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
Loading

0 comments on commit acd53c9

Please sign in to comment.