From 4a4bd3bdf607abfe429ec66b14feb136b2e535c9 Mon Sep 17 00:00:00 2001 From: Guido Flohr Date: Tue, 3 Dec 2024 08:22:10 +0200 Subject: [PATCH 1/7] fix typo --- documentation/Mapping.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/documentation/Mapping.md b/documentation/Mapping.md index 421dc91..886f396 100644 --- a/documentation/Mapping.md +++ b/documentation/Mapping.md @@ -3,19 +3,19 @@ Mappings map cells from an invoice spreadsheet file to invoice data. - [Mapping](#mapping) - - [Format](#format) - - [General Structure](#general-structure) - - [The `meta` Object](#the-meta-object) - - [The `meta.sectionColumn` Object](#the-metasectioncolumn-object) - - [The `meta.empty` Array](#the-metaempty-array) - - [The `ubl:Invoice` Object](#the-ublinvoice-object) - - [Literal Values](#literal-values) - - [Sheet References](#sheet-references) - - [Section References](#section-references) - - [Cell References](#cell-references) - - [Formulas](#formulas) - - [Surprising Arrays](#surprising-arrays) - - [Examples](#examples) + - [Format](#format) + - [General Structure](#general-structure) + - [The `meta` Object](#the-meta-object) + - [The `meta.sectionColumn` Object](#the-metasectioncolumn-object) + - [The `meta.empty` Array](#the-metaempty-array) + - [The `ubl:Invoice` Object](#the-ublinvoice-object) + - [Literal Values](#literal-values) + - [Sheet References](#sheet-references) + - [Section References](#section-references) + - [Cell References](#cell-references) + - [Formulas](#formulas) + - [Surprising Arrays](#surprising-arrays) + - [Examples](#examples) ## Format @@ -122,7 +122,7 @@ ubl:Invoice: Because of the way that YAML works, you must also quote the strings "null", "true", and "false". Especially, the value of `cbc:ChargeIndicator` inside `cac:AllowanceCharge` sections must be one of the strings "true" or "false", -and not +and not the literals `true` or `false`. #### Sheet References @@ -228,10 +228,10 @@ formular, not the formula itself. ## Surprising Arrays -Some elements are arrays although this will often be surprising. For example, -the element [`/ubl:Invoice/cac:TaxTotal`] is an array with 1-2 elements. But +Some elements are arrays although this will often be surprising. For example, +the element [`/ubl:Invoice/cac:TaxTotal`] is an array with 1-2 elements. But you will almost always have just one element here. In this case, there is -no need for a section, you can simply omit the `section` property. You will +no need for a section, you can simply omit the `section` property. You will probably be using this feature without even noticing it. ## Examples From fd7ae3f46e89360574e04b05dcb82eb4e5a6ede8 Mon Sep 17 00:00:00 2001 From: Guido Flohr Date: Tue, 3 Dec 2024 09:40:40 +0200 Subject: [PATCH 2/7] containerize application This fixes #16. --- .dockerignore | 4 ++++ Dockerfile | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..975348f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +Dockerfile +.dockerignore +dist +node_modules diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..33028ff --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM alpine:latest + +ENV NODE_ENV=production +ENV LIBREOFFICE=libreoffice + +RUN apk add --no-cache \ + bash \ + curl \ + libreoffice \ + libc6-compat \ + npm \ + ttf-freefont \ + font-noto \ + font-noto-cjk \ + font-noto-emoji + +RUN curl -fsSL https://bun.sh/install | bash && \ + ln -s /root/.bun/bin/bun /usr/local/bin/bun + +WORKDIR /app + +COPY . . + +# Avoid "/bin/bash: line 1: husky: command not found"! +RUN bun install husky + +RUN bun install --production + +RUN echo "export LIBREOFFICE=\${LIBREOFFICE:-libreoffice}" >> /etc/profile.d/libreoffice.sh + +EXPOSE 3000 + +CMD ["bun", "run", "start"] From 98e1b5121d5cdc27f02be25604010d622ed042ca Mon Sep 17 00:00:00 2001 From: Guido Flohr Date: Tue, 3 Dec 2024 09:43:16 +0200 Subject: [PATCH 3/7] add files to .dockerignore --- .dockerignore | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.dockerignore b/.dockerignore index 975348f..2f12d9f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,20 @@ Dockerfile .dockerignore +.editorconfig +.gitignore +.gitmodules +.husky +.nvmrc +.prettierrc +.vscode +contrib +coverage dist +documentation +log node_modules +peppol-bis-invoice-3 +scripts +test +Makefile +README.md From 8e5a46681940be483e0c8c8cdebb7fec620c2a6a Mon Sep 17 00:00:00 2001 From: Guido Flohr Date: Tue, 3 Dec 2024 09:55:01 +0200 Subject: [PATCH 4/7] use multi-stage build --- Dockerfile | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 33028ff..9d00576 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM alpine:latest +# Stage 1: Build stage +FROM alpine:latest AS builder ENV NODE_ENV=production ENV LIBREOFFICE=libreoffice @@ -6,13 +7,8 @@ ENV LIBREOFFICE=libreoffice RUN apk add --no-cache \ bash \ curl \ - libreoffice \ - libc6-compat \ npm \ - ttf-freefont \ - font-noto \ - font-noto-cjk \ - font-noto-emoji + libc6-compat RUN curl -fsSL https://bun.sh/install | bash && \ ln -s /root/.bun/bin/bun /usr/local/bin/bun @@ -23,9 +19,30 @@ COPY . . # Avoid "/bin/bash: line 1: husky: command not found"! RUN bun install husky - RUN bun install --production +# Stage 2: Runtime stage +FROM alpine:latest + +ENV NODE_ENV=production +ENV LIBREOFFICE=libreoffice + +RUN apk add --no-cache \ + bash \ + curl \ + libreoffice \ + ttf-freefont \ + font-noto \ + font-noto-cjk \ + font-noto-emoji + +WORKDIR /app +COPY --from=builder /app /app + +# Copy the bun binary from the build stage to runtime +COPY --from=builder /root/.bun /root/.bun +RUN ln -s /root/.bun/bin/bun /usr/local/bin/bun + RUN echo "export LIBREOFFICE=\${LIBREOFFICE:-libreoffice}" >> /etc/profile.d/libreoffice.sh EXPOSE 3000 From feb3d49012dce3d9d72cbdae780cbccadf60565a Mon Sep 17 00:00:00 2001 From: Guido Flohr Date: Tue, 3 Dec 2024 10:03:59 +0200 Subject: [PATCH 5/7] document container usage --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index eb158a8..cb2c6fa 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ formats or JSON. - [Installation](#installation) - [Running the app](#running-the-app) - [Test](#test) + - [Running in a Container](#running-in-a-container) - [Curl Examples](#curl-examples) - [OpenAPI/Swagger documentation](#openapiswagger-documentation) - [List Supported Formats](#list-supported-formats) @@ -119,6 +120,33 @@ $ bun run test:e2e $ bun run test:cov ``` +## Running in a Container + +By far the easiest way is to run the application in a software container. + +Pull the Docker image with either one of these commands: + +```sh +$ nerdctl pull gflohr/e-einvoice-eu:latest +$ docker pull gflohr/e-invoice-eu:latest +``` + +Run the container with either one of these commands: + +```sh +$ nerdctl run --rm -d -p 3000:3000 --name e-invoice-eu gflohr/e-invoice-eu:1.0.0 +$ docker run --rm -d -p 3000:3000 --name e-invoice-eu gflohr/e-invoice-eu:1.0.0 +``` + +If you want to debug issues, omit the option `-d` so that you can see the +output of the application running inside of the container. + +Access the application from your host computer: + +```sh +$ curl http://localhost:3000/api/format/list +``` + ## Curl Examples The following assumes that you run the application with `start:dev` and the From cfb9fed42642d1f6f21705008631ef9e863cc809 Mon Sep 17 00:00:00 2001 From: Guido Flohr Date: Tue, 3 Dec 2024 10:04:11 +0200 Subject: [PATCH 6/7] bump version number to 1.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ad2caee..9385721 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "e-invoice-eu", - "version": "0.1.0", + "version": "1.0.0", "repository": { "type": "git", "url": "git+https://github.com/gflohr/e-invoice-eu.git" From b2e04371eab6904bdff28411739d95cb842c49dd Mon Sep 17 00:00:00 2001 From: Guido Flohr Date: Tue, 3 Dec 2024 10:06:15 +0200 Subject: [PATCH 7/7] use only docker, not nerdctl Users will have an alias installed. --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cb2c6fa..cd9cbbc 100644 --- a/README.md +++ b/README.md @@ -124,17 +124,15 @@ $ bun run test:cov By far the easiest way is to run the application in a software container. -Pull the Docker image with either one of these commands: +Pull the Docker image: ```sh -$ nerdctl pull gflohr/e-einvoice-eu:latest $ docker pull gflohr/e-invoice-eu:latest ``` -Run the container with either one of these commands: +Run the container: ```sh -$ nerdctl run --rm -d -p 3000:3000 --name e-invoice-eu gflohr/e-invoice-eu:1.0.0 $ docker run --rm -d -p 3000:3000 --name e-invoice-eu gflohr/e-invoice-eu:1.0.0 ```