image update
This commit is contained in:
@@ -1 +1,2 @@
|
||||
export PROJ=/home/esilva/Desktop/projetos/fax
|
||||
registry=git.esilva.org
|
||||
repo=esilva
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ RUN apk --no-cache add bash zsh go make sqlite \
|
||||
|
||||
|
||||
# Copy the source files
|
||||
COPY ./src /frontend-src
|
||||
COPY ./src/build /frontend
|
||||
|
||||
|
||||
# Add the entrypoint
|
||||
|
||||
@@ -1,17 +1,27 @@
|
||||
include vars.mk
|
||||
build = ./build/expensesweb
|
||||
image = $(registry)/$(repo)/fax-frontend:$(tag)
|
||||
|
||||
build:
|
||||
docker buildx build -t esilva-fax .
|
||||
make -C src build_release_alpine
|
||||
|
||||
build_image: build
|
||||
podman buildx build -t $(image) .
|
||||
|
||||
push_image:
|
||||
podman push $(image)
|
||||
|
||||
clean:
|
||||
docker container rm esilva-fax-container-test --force
|
||||
podman container rm esilva-fax-container-test --force
|
||||
|
||||
attach:
|
||||
docker exec -u root -it esilva-fax-container zsh
|
||||
podman exec -u root -it esilva-fax-container zsh
|
||||
|
||||
attach-test:
|
||||
docker exec -u root -it esilva-fax-container-test zsh
|
||||
podman exec -u root -it esilva-fax-container-test zsh
|
||||
|
||||
test: clean
|
||||
docker run \
|
||||
podman run \
|
||||
--name esilva-fax-container-test \
|
||||
-v ./data.db:/data.db \
|
||||
-v ./src/config.yml:/etc/fax/config.yml \
|
||||
|
||||
@@ -4,4 +4,4 @@ These faxes will be printed on a thermal printer. Pretty neat.
|
||||
|
||||
# Docker
|
||||
You need to mount the `data.db` sqlit3 DB on `/data.db` in the container.
|
||||
We should change this to a more appropriate location tho.
|
||||
We should change this to a more appropriate location.
|
||||
|
||||
@@ -1,16 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ ! -d /frontend ]; then
|
||||
export GOPROXY="https://goproxy.io"
|
||||
cd /frontend-src
|
||||
make clean
|
||||
make build
|
||||
mv build /frontend
|
||||
cd ..
|
||||
rm -r /frontend-src
|
||||
ln -s /data.db /frontend/data.db
|
||||
fi
|
||||
|
||||
cd /frontend
|
||||
exec ./frontend --config "/etc/fax/config.yml"
|
||||
|
||||
@@ -3,6 +3,11 @@ build: clean
|
||||
go build -o build/frontend
|
||||
cp -r ./assets build
|
||||
|
||||
build_release_alpine: clean
|
||||
mkdir build
|
||||
CGO_ENABLED=1 GOOS=linux CC=musl-gcc go build -o build/frontend
|
||||
cp -r ./assets build
|
||||
|
||||
clean:
|
||||
rm -rf ./build
|
||||
|
||||
|
||||
+1
-2
@@ -4,6 +4,5 @@ network:
|
||||
port: "9099"
|
||||
usb:
|
||||
path: "/dev/usb/lp0"
|
||||
fake:
|
||||
|
||||
dbpath: "./data.db"
|
||||
dbpath: "/data.db"
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
use: "network"
|
||||
network:
|
||||
host: "127.0.0.1"
|
||||
port: "9099"
|
||||
usb:
|
||||
path: "/dev/usb/lp0"
|
||||
|
||||
dbpath: "./data.db"
|
||||
@@ -98,12 +98,18 @@ func (c *Configuration) loadConfiguration(data []byte) error {
|
||||
errStr := fmt.Sprintf("failed to read file: %s", err)
|
||||
return errors.New(errStr)
|
||||
}
|
||||
|
||||
log.Println("Loaded configuration from: ", c.Path)
|
||||
}
|
||||
|
||||
log.Println("Config RAW: ", contents)
|
||||
|
||||
err := cparser.parseConfigFile(contents)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Println("Parsed Config: ", c)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -86,9 +86,6 @@ func SendFax(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// REMOVE THIS YO
|
||||
// time.Sleep(3 * time.Second)
|
||||
|
||||
// Create the model access
|
||||
var dacc models.DB
|
||||
m, err := models.NewModel(&dacc)
|
||||
@@ -122,11 +119,13 @@ func SendFax(w http.ResponseWriter, r *http.Request) {
|
||||
msg := signMessage(message.Text, user.Name, mDate.Format("2006-01-02 15:04:05"))
|
||||
_, err = sendRequestToPrinter(msg)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to send message: %v\n", err)
|
||||
// When we have our history table working we can set the state of it here
|
||||
// log.Println("printer failed to process fax:", err)
|
||||
// w.Write([]byte("{\"state\":\"failed\"}"))
|
||||
// return
|
||||
}
|
||||
log.Printf("Message sent: %v\n", msg)
|
||||
|
||||
/*
|
||||
Another workflow to add here is to send the message into the DB right away
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log"
|
||||
|
||||
"thermalFax/config"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
@@ -43,5 +44,7 @@ func (d *DB) openDB() (*sql.DB, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Println("opened DB on: ", cfg.DBPath)
|
||||
|
||||
return db, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user