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 the source files
|
||||||
COPY ./src /frontend-src
|
COPY ./src/build /frontend
|
||||||
|
|
||||||
|
|
||||||
# Add the entrypoint
|
# Add the entrypoint
|
||||||
|
|||||||
@@ -1,17 +1,27 @@
|
|||||||
|
include vars.mk
|
||||||
|
build = ./build/expensesweb
|
||||||
|
image = $(registry)/$(repo)/fax-frontend:$(tag)
|
||||||
|
|
||||||
build:
|
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:
|
clean:
|
||||||
docker container rm esilva-fax-container-test --force
|
podman container rm esilva-fax-container-test --force
|
||||||
|
|
||||||
attach:
|
attach:
|
||||||
docker exec -u root -it esilva-fax-container zsh
|
podman exec -u root -it esilva-fax-container zsh
|
||||||
|
|
||||||
attach-test:
|
attach-test:
|
||||||
docker exec -u root -it esilva-fax-container-test zsh
|
podman exec -u root -it esilva-fax-container-test zsh
|
||||||
|
|
||||||
test: clean
|
test: clean
|
||||||
docker run \
|
podman run \
|
||||||
--name esilva-fax-container-test \
|
--name esilva-fax-container-test \
|
||||||
-v ./data.db:/data.db \
|
-v ./data.db:/data.db \
|
||||||
-v ./src/config.yml:/etc/fax/config.yml \
|
-v ./src/config.yml:/etc/fax/config.yml \
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ These faxes will be printed on a thermal printer. Pretty neat.
|
|||||||
|
|
||||||
# Docker
|
# Docker
|
||||||
You need to mount the `data.db` sqlit3 DB on `/data.db` in the container.
|
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
|
#!/bin/sh
|
||||||
set -e
|
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
|
cd /frontend
|
||||||
exec ./frontend --config "/etc/fax/config.yml"
|
exec ./frontend --config "/etc/fax/config.yml"
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ build: clean
|
|||||||
go build -o build/frontend
|
go build -o build/frontend
|
||||||
cp -r ./assets build
|
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:
|
clean:
|
||||||
rm -rf ./build
|
rm -rf ./build
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -4,6 +4,5 @@ network:
|
|||||||
port: "9099"
|
port: "9099"
|
||||||
usb:
|
usb:
|
||||||
path: "/dev/usb/lp0"
|
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)
|
errStr := fmt.Sprintf("failed to read file: %s", err)
|
||||||
return errors.New(errStr)
|
return errors.New(errStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Println("Loaded configuration from: ", c.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Println("Config RAW: ", contents)
|
||||||
|
|
||||||
err := cparser.parseConfigFile(contents)
|
err := cparser.parseConfigFile(contents)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Println("Parsed Config: ", c)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,9 +86,6 @@ func SendFax(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// REMOVE THIS YO
|
|
||||||
// time.Sleep(3 * time.Second)
|
|
||||||
|
|
||||||
// Create the model access
|
// Create the model access
|
||||||
var dacc models.DB
|
var dacc models.DB
|
||||||
m, err := models.NewModel(&dacc)
|
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"))
|
msg := signMessage(message.Text, user.Name, mDate.Format("2006-01-02 15:04:05"))
|
||||||
_, err = sendRequestToPrinter(msg)
|
_, err = sendRequestToPrinter(msg)
|
||||||
if err != nil {
|
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
|
// When we have our history table working we can set the state of it here
|
||||||
// log.Println("printer failed to process fax:", err)
|
// log.Println("printer failed to process fax:", err)
|
||||||
// w.Write([]byte("{\"state\":\"failed\"}"))
|
// w.Write([]byte("{\"state\":\"failed\"}"))
|
||||||
// return
|
// return
|
||||||
}
|
}
|
||||||
|
log.Printf("Message sent: %v\n", msg)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Another workflow to add here is to send the message into the DB right away
|
Another workflow to add here is to send the message into the DB right away
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"thermalFax/config"
|
"thermalFax/config"
|
||||||
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
@@ -43,5 +44,7 @@ func (d *DB) openDB() (*sql.DB, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Println("opened DB on: ", cfg.DBPath)
|
||||||
|
|
||||||
return db, nil
|
return db, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user