Dockerize backend server (#8)

Dockerize backend server

Co-authored-by: Leo <legacyofleo@gmail.com>
This commit is contained in:
Johannes Müller-Werner 2020-12-17 08:32:57 +01:00 committed by GitHub
parent 230441263f
commit 1983783f9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 85 additions and 0 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@
build/
server/config.js
server/package-lock.json
server/docker-compose.yml

View file

@ -63,3 +63,28 @@ fields:
- `author` (string): Optional author name to add to the annotation metadata.
- `modified` (number): Optional timestamp (seconds since the epoch, in UTC)
when the annotation was last modified.
# Run pdfdraw server in a docker container using docker-compose.
All settings are exposed into enviroment variables. That means you are able to config the backend server in [docker-compose.yml](docker-compose.yml.in) yaml file by editing the corresponding enviroment variables.
Save `docker-compose.yml.in` to `docker-compose.yml` and make changes if needed.
Based on your docker setup you still need to edit a few lines in the `docker-compose.yml` file for networking.
For example by exposing ports:
ports:
- "8080:8080"
or join an existing network:
networks:
default:
external:
name: my-pre-existing-network
For more details read [Networking in Compose](https://docs.docker.com/compose/networking/)
Than run docker compose.
docker-compose up -d

View file

@ -0,0 +1,22 @@
version: '2'
services:
pdfdraw-server:
build:
context: .
dockerfile: docker/Dockerfile
environment:
port: 8080
secret: 'the-shared-secret'
#allow_invalid_certificates: null
#use_auto_ecdh_curve: null
#cmd_pdftk: ''
#cmd_svg2pdf: ''
#ports:
#- '8080:8080'
#networks:
# default:
# external:
# name: my-pre-existing-network

13
server/docker/Dockerfile Normal file
View file

@ -0,0 +1,13 @@
FROM nikolaik/python-nodejs:python3.9-nodejs15
ADD . /app
ADD docker/config.js.docker /app/config.js
RUN apt-get update || : && apt-get install pdftk python-pypdf2 -y
WORKDIR /app
RUN pip install svglib
RUN npm install
CMD ["node", "server.js"]

View file

@ -0,0 +1,24 @@
var config = {};
// The port the service should run on.
config.port = process.env.port || 8080;
// The shared secret for token validation. Must be the same value
// as configured in the Nextcloud admin interface.
config.secret = process.env.secret || 'the-shared-secret';
// INSECURE! Allow any self-signed / expired certificates.
// Only use this during development!
config.allow_invalid_certificates = process.env.allow_invalid_certificates || false;
// Required for newer versions of node / libssl.
// See https://github.com/nodejs/node/issues/21513#issuecomment-399790415
config.use_auto_ecdh_curve = process.env.use_auto_ecdh_curve || false;
// Command to use when running pdftk. Defaults to 'pdftk' if not configured.
config.cmd_pdftk = process.env.cmd_pdftk || '';
// Command to use when running svg2pdf. Defaults to 'svg2pdf' if not configured.
config.cmd_svg2pdf = process.env.cmd_svg2pdf || '';
module.exports = config;