From 263de1052a6402d617ecb3e216fb1debeda30b1a Mon Sep 17 00:00:00 2001 From: Peter Magnusson Date: Fri, 18 Nov 2022 15:55:36 +0100 Subject: [PATCH 1/5] install more fonts --- .devcontainer/Dockerfile | 52 ++++++++++++++++++++--------- Dockerfile | 70 ++++++++++++++++++++++++++-------------- 2 files changed, 83 insertions(+), 39 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 5734634..3031e11 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,15 +1,37 @@ -FROM node:alpine - -RUN apk add libreoffice ffmpeg imagemagick tesseract-ocr - - -RUN apk add msttcorefonts-installer && \ - update-ms-fonts && \ - fc-cache -f - -RUN apk add --update openjdk11 -RUN java --version - -# differs from production dockerfile -RUN apk add git - +FROM node:alpine + +RUN apk add libreoffice ffmpeg imagemagick tesseract-ocr + + +RUN apk add msttcorefonts-installer && \ + update-ms-fonts && \ + fc-cache -f + +RUN apk add --update openjdk11 +RUN java --version + +RUN apk search -qe 'font-bitstream-*' | xargs apk add \ + && apk add \ + font-arabic-misc \ + font-daewoo-misc \ + ttf-inconsolata \ + font-ipa \ + font-isas-misc \ + font-jis-misc \ + font-misc-misc \ + font-noto \ + font-noto-extra \ + font-noto-thai \ + font-noto-tibetan \ + font-noto-cjk \ + font-sony-misc \ + terminus-font \ + ttf-inconsolata \ + ttf-dejavu \ + ttf-font-awesome \ + && fc-cache -fv + + +# differs from production dockerfile +RUN apk add git + diff --git a/Dockerfile b/Dockerfile index e510092..76a8bef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,46 @@ -FROM node:alpine - -RUN apk add libreoffice ffmpeg imagemagick tesseract-ocr - - -RUN apk add msttcorefonts-installer && \ - update-ms-fonts && \ - fc-cache -f - -RUN apk add --update openjdk11 -RUN java --version - -WORKDIR /usr/src/app - -COPY package.json . -COPY package-lock.json . - -RUN npm install && npm audit fix --force - -COPY . . - -EXPOSE 3000 - -CMD [ "node", "index.js" ] +FROM node:alpine + +RUN apk add libreoffice ffmpeg imagemagick tesseract-ocr + + +RUN apk add msttcorefonts-installer && \ + update-ms-fonts && \ + fc-cache -f + +RUN apk add --update openjdk11 +RUN java --version + +RUN apk search -qe 'font-bitstream-*' | xargs apk add \ + && apk add \ + font-arabic-misc \ + font-daewoo-misc \ + ttf-inconsolata \ + font-ipa \ + font-isas-misc \ + font-jis-misc \ + font-misc-misc \ + font-noto \ + font-noto-extra \ + font-noto-thai \ + font-noto-tibetan \ + font-noto-cjk \ + font-sony-misc \ + terminus-font \ + ttf-inconsolata \ + ttf-dejavu \ + ttf-font-awesome \ + && fc-cache -fv + + +WORKDIR /usr/src/app + +COPY package.json . +COPY package-lock.json . + +RUN npm install && npm audit fix --force + +COPY . . + +EXPOSE 3000 + +CMD [ "npm", "start" ] From 503200d3a0d3a2cb52c5987baf6758a21b1e672a Mon Sep 17 00:00:00 2001 From: Peter Magnusson Date: Fri, 18 Nov 2022 15:55:53 +0100 Subject: [PATCH 2/5] do not include .devcontainer --- .dockerignore | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.dockerignore b/.dockerignore index f31cd6c..f8f1cfe 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,5 @@ -.git -node_modules -test -*.log \ No newline at end of file +.devcontainer +.git +node_modules +test +*.log From c067848a88a664e6bbf2535fad158294a09cbc63 Mon Sep 17 00:00:00 2001 From: Peter Magnusson Date: Fri, 18 Nov 2022 15:56:04 +0100 Subject: [PATCH 3/5] example of compose file --- docker-compose.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8c331b7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.7' + +services: + versed: + build: . + ports: + - 3000:3000 + restart: "on-failure" + environment: + - DEBUG=versed* From 0907e86f7bd40e1271312c8951493ab846efe08e Mon Sep 17 00:00:00 2001 From: Peter Magnusson Date: Fri, 18 Nov 2022 15:12:53 +0000 Subject: [PATCH 4/5] omit dev dependencies --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 76a8bef..90f6683 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,7 +37,9 @@ WORKDIR /usr/src/app COPY package.json . COPY package-lock.json . -RUN npm install && npm audit fix --force +ENV NODE_ENV production + +RUN npm install --omit=dev && npm audit fix --omit=dev --force COPY . . From 623979d73dcc7f72d6f395b2d398c9ebbcdda122 Mon Sep 17 00:00:00 2001 From: Peter Magnusson Date: Fri, 18 Nov 2022 15:13:09 +0000 Subject: [PATCH 5/5] fix naming of some tests --- test/test_utils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_utils.js b/test/test_utils.js index a890337..edbef65 100644 --- a/test/test_utils.js +++ b/test/test_utils.js @@ -5,20 +5,20 @@ import * as util from '../util.js'; describe('Util', function () { describe('#mimetype()', function () { - it('should return type image of format png for "testing.png"', function () { + it('should return type "image" of format "png" for "testing.png"', function () { const res = util.mimetype('testing.png'); assert.equal(res.type, 'image'); assert.equal(res.format, 'png'); }); - it('should return type image of format png for "testing.docx"', function () { + it('should return type "application" of format "vnd.openxmlformats-officedocument.wordprocessingml.document" for "testing.docx"', function () { const res = util.mimetype('testing.docx'); assert.equal(res.full, 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'); assert.equal(res.type, 'application'); assert.equal(res.format, 'vnd.openxmlformats-officedocument.wordprocessingml.document'); }); - it('should return type image of format png for "testing.mkv"', function () { + it('should return type "video" of format "x-matroska" for "testing.mkv"', function () { const res = util.mimetype('testing.mkv'); assert.equal(res.full, 'video/x-matroska'); assert.equal(res.type, 'video');