Repository: paperless-ngx/paperless-ngx

Issue:
[BUG] Regression in docker build
### Description

I cannot locally build the docker image. 
The error message is
```
FROM ghcr.io/${REPO}/builder/jbig2enc:${JBIG2ENC_VERSION} as jbig2enc-builder
invalid reference format
```

I did a git bisect and this came out:
```
6c70db31bd78d166f06ace734761824239aeb3e4 is the first bad commit
commit 6c70db31bd78d166f06ace734761824239aeb3e4
Author: Trenton Holmes <holmes.trenton@gmail.com>
Date:   Mon Apr 18 08:18:20 2022 -0700

    Incorporates the base image building back into the main repo with multi stage building

 .github/workflows/ci.yml                        | 313 +++++++++++++++---------
 .github/workflows/reusable-ci-backend.yml       | 108 ++++++++
 .github/workflows/reusable-ci-frontend.yml      |  42 ++++
 .github/workflows/reusable-workflow-builder.yml |  68 +++++
 .pre-commit-config.yaml                         |  13 +-
 Dockerfile                                      | 147 +++++++++--
 docker-builders/Dockerfile.frontend             |  13 +
 docker-builders/Dockerfile.jbig2enc             |  39 +++
 docker-builders/Dockerfile.pikepdf              |  65 +++++
 docker-builders/Dockerfile.psycopg2             |  44 ++++
 docker-builders/Dockerfile.qpdf                 |  51 ++++
 docker-builders/get-build-json.py               | 112 +++++++++
 docker/docker-prepare.sh                        |   2 +
 docker/install_management_commands.sh           |   2 +
 14 files changed, 877 insertions(+), 142 deletions(-)
 create mode 100644 .github/workflows/reusable-ci-backend.yml
 create mode 100644 .github/workflows/reusable-ci-frontend.yml
 create mode 100644 .github/workflows/reusable-workflow-builder.yml
 create mode 100644 docker-builders/Dockerfile.frontend
 create mode 100644 docker-builders/Dockerfile.jbig2enc
 create mode 100644 docker-builders/Dockerfile.pikepdf
 create mode 100644 docker-builders/Dockerfile.psycopg2
 create mode 100644 docker-builders/Dockerfile.qpdf
 create mode 100755 docker-builders/get-build-json.py
```
So 6c70db31bd78d166f06ace734761824239aeb3e4 is the first bad commit. @stumpylog can you have a look? It seems you do a ton of magic in the CI pipeline and I am unsure how to reproduce this locally..

### Steps to reproduce

1. git checkout dev
2. docker build .

### Webserver logs

_No response_

### Screenshots

_No response_

### Paperless-ngx version

dev

### Host OS

NixOS

### Installation method

Docker

### Browser

Brave

### Configuration changes

_No response_

### Other

_No response_


Discussion:
Ok, nevermind, I missed the `build-docker-image.sh` which sets all the variables needed.. :roll_eyes: 
I'm actually going to re-open this to track making the Docker building process locally somehow better.  Though the build script works, it's not (yet) ideal for locally testing out some changes.  I'm hoping to have some new idea to fix it, but nothing much yet.

- Choosing a different frontend build requires manually editing the `Dockerfile`
- Backend files are copied from the frontend build (instead of local dir), making changes there also require manual edits
- Probably more I haven't encountered

Resolving patch:
diff --git a/.github/scripts/get-build-json.py b/.github/scripts/get-build-json.py
--- a/.github/scripts/get-build-json.py
+++ b/.github/scripts/get-build-json.py
@@ -53,10 +53,7 @@ def _main():
     git_tag = None
     extra_config = {}
 
-    if args.package == "frontend":
-        # Version is just the branch or tag name
-        version = branch_name
-    elif args.package in pipfile_data["default"]:
+    if args.package in pipfile_data["default"]:
         # Read the version from Pipfile.lock
         pkg_data = pipfile_data["default"][args.package]
         pkg_version = pkg_data["version"].split("==")[-1]


Test patch: