diff --git a/Dockerfile b/Dockerfile index 372d2d4..91bf350 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,17 +4,11 @@ FROM alpine:20231219 ENV TZ="Europe/Lisbon" -# Install the required packages -RUN apk --no-cache add bash zsh go make \ - && rm -rf /tmp/* - - # Copy the source files COPY ../src /printer-src # Add the entrypoint -USER $UNAME COPY ./start.sh /start.sh STOPSIGNAL SIGTERM ENTRYPOINT [ "/start.sh" ] diff --git a/Makefile b/Makefile index eccbc7e..ef4324a 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,25 @@ -build: - docker buildx build -t thprinter . +include vars.mk + +image = $(registry)/$(repo)/$(name):$(tag) + +build_image: + make -B -C src build + podman buildx build -t $(image) . + +push_image: + podman push $(image) clean: - docker container rm thprinter-container-test --force + podman container rm thprinter-container-test --force attach: - docker exec -u root -it thprinter-container zsh + podman exec -u root -it thprinter-container zsh attach-test: - docker exec -u root -it thprinter-container-test zsh + podman exec -u root -it thprinter-container-test zsh test: clean - docker run \ + podman run \ --name thprinter-container-test \ -p 9099:9099 \ -it thprinter zsh diff --git a/README.md b/README.md index f173b05..8a6e518 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,16 @@ Copy the `capabilities.json` file you generated into the `src` directory of this project. +## How to find the printer +On my specific printer: +- turn off +- hold the feed button +- turn it on +- hold the feed button until the lights blink red +- release button +- test page will print with network settings + + ## Running it Go to the `src` directory and try it with: `$ echo "Something, something" | go run .` diff --git a/src/Makefile b/src/Makefile index 78b2d85..2c2b93a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,7 @@ -build: +build: clean mkdir build - go build -o build/printer + CGO_ENABLED=1 GOOS=linux CC=musl-gcc \ + go build -o build/printer cp ./capabilities.json ./build/ cp ./config.yaml ./build/ diff --git a/start.sh b/start.sh index 34a7bdf..a988062 100755 --- a/start.sh +++ b/start.sh @@ -1,17 +1,5 @@ #!/bin/sh set -e -# echo "nameserver 8.8.8.8" >> /etc/resolv.conf - -if [ ! -d /printer ]; then - export GOPROXY="https://goproxy.io" - cd /printer-src - make clean - make build - mv build /printer - cd .. - rm -r /printer-src -fi - cd /printer exec ./printer server diff --git a/vars.mk b/vars.mk new file mode 100644 index 0000000..b45b692 --- /dev/null +++ b/vars.mk @@ -0,0 +1,6 @@ +include $(dir $(lastword $(MAKEFILE_LIST))).env + +REQUIRED_VARS := registry repo name tag + +$(foreach v,$(REQUIRED_VARS),\ + $(if $(value $(v)),,$(error Variable '$(v)' is required but empty)))