From 762d1baea436b19027a0226ffe88af67069f7af0 Mon Sep 17 00:00:00 2001 From: Finn Date: Tue, 23 Apr 2024 20:28:26 -0700 Subject: [PATCH] fix arm build by dropping sqlite3 cgo dep --- .forgejo/workflows/docker-build.yaml | 2 +- Containerfile | 4 ++-- db/helpers.go | 4 ++-- go.mod | 12 +++++++++++- go.sum | 4 ++++ lockserver.defaults.json | 2 +- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.forgejo/workflows/docker-build.yaml b/.forgejo/workflows/docker-build.yaml index a18dab0..3281e78 100644 --- a/.forgejo/workflows/docker-build.yaml +++ b/.forgejo/workflows/docker-build.yaml @@ -18,5 +18,5 @@ jobs: file: Containerfile tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - platforms: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/arm/v7 push: true diff --git a/Containerfile b/Containerfile index 00f45f7..35afa7a 100644 --- a/Containerfile +++ b/Containerfile @@ -18,8 +18,8 @@ FROM alpine:latest AS build RUN apk add --no-cache go ADD . /go/lockserver WORKDIR /go/lockserver -RUN go build ./cmd/lockserver +RUN CGO_ENABLED=0 go build ./cmd/lockserver -FROM alpine:latest +FROM scratch COPY --from=build /go/lockserver/lockserver /lockserver ENTRYPOINT ["/lockserver"] diff --git a/db/helpers.go b/db/helpers.go index 0a0ee40..c49f805 100644 --- a/db/helpers.go +++ b/db/helpers.go @@ -5,15 +5,15 @@ import ( "database/sql" "embed" - _ "github.com/mattn/go-sqlite3" goose "github.com/pressly/goose/v3" "github.com/sirupsen/logrus" + _ "modernc.org/sqlite" "git.janky.solutions/finn/lockserver/config" ) func Get() (*Queries, *sql.DB, error) { - db, err := sql.Open("sqlite3", config.C.SqliteDatabase) + db, err := sql.Open("sqlite", config.C.SqliteDatabase) if err != nil { return nil, nil, err } diff --git a/go.mod b/go.mod index cba4bb2..e959c8b 100644 --- a/go.mod +++ b/go.mod @@ -8,16 +8,18 @@ require ( github.com/google/uuid v1.6.0 github.com/gorilla/websocket v1.5.1 github.com/labstack/echo/v4 v4.11.4 - github.com/mattn/go-sqlite3 v1.14.22 github.com/oapi-codegen/runtime v1.1.1 github.com/pressly/goose/v3 v3.19.2 github.com/sirupsen/logrus v1.9.3 + modernc.org/sqlite v1.29.5 ) require ( github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect github.com/go-openapi/jsonpointer v0.20.2 // indirect github.com/go-openapi/swag v0.22.8 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/invopop/yaml v0.2.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/labstack/gommon v0.4.2 // indirect @@ -26,7 +28,9 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mfridman/interpolate v0.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect + github.com/ncruces/go-strftime v0.1.9 // indirect github.com/perimeterx/marshmallow v1.1.5 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/sethvargo/go-retry v0.2.4 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect @@ -37,4 +41,10 @@ require ( golang.org/x/sys v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect + modernc.org/libc v1.41.0 // indirect + modernc.org/mathutil v1.6.0 // indirect + modernc.org/memory v1.7.2 // indirect + modernc.org/strutil v1.2.0 // indirect + modernc.org/token v1.1.0 // indirect ) diff --git a/go.sum b/go.sum index c9eb1e8..c554c57 100644 --- a/go.sum +++ b/go.sum @@ -62,6 +62,8 @@ github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOW github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ= +github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -224,6 +226,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM= howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= +modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE= +modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ= modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI= modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4= modernc.org/libc v1.41.0 h1:g9YAc6BkKlgORsUWj+JwqoB1wU3o4DE3bM3yvA3k+Gk= diff --git a/lockserver.defaults.json b/lockserver.defaults.json index 02b3712..9749ca4 100644 --- a/lockserver.defaults.json +++ b/lockserver.defaults.json @@ -1,5 +1,5 @@ { "zwave-js-server": "ws://home-assistant:3000", - "sqlite-database": "lockserver.db", + "sqlite-database": "/data/lockserver.db", "http-bind": ":8080" }