Skip to content

Commit

Permalink
Merge pull request #45 from gflohr/16-create-dockerfile
Browse files Browse the repository at this point in the history
16 create dockerfile
  • Loading branch information
gflohr authored Dec 3, 2024
2 parents b60289e + b2e0437 commit fedb9f6
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 18 deletions.
20 changes: 20 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +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
50 changes: 50 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Stage 1: Build stage
FROM alpine:latest AS builder

ENV NODE_ENV=production
ENV LIBREOFFICE=libreoffice

RUN apk add --no-cache \
bash \
curl \
npm \
libc6-compat

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

# 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

CMD ["bun", "run", "start"]
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -119,6 +120,31 @@ $ 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:

```sh
$ docker pull gflohr/e-invoice-eu:latest
```

Run the container:

```sh
$ 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
Expand Down
34 changes: 17 additions & 17 deletions documentation/Mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit fedb9f6

Please sign in to comment.