I am setting up a Spatialite database (SQLite + Spatialite extension) and an associated Go program running in a docker container that queries the database and returns data.
Go-spatialite, in my understanding will dynamically load the spatialite library at runtime in order to query the database. Everything runs fine when running the Go program locally and querying the service with Postman.
However, when using the container, the Go program fails to find the spatialite extension:
"error":"shaxbee/go-spatialite: spatialite extension not found."
I use go-spatialite (shaxbee) package and database/sql
package. I have installed Spatialite locally.
I open the database connection like this:
db, err := sql.Open("spatialite", "path/to/my/db")
if err != nil {
logVar.WithError(err).Fatal("Impossible to open database")
}
if err := db.Ping(); err != nil {
logVar.WithError(err).Fatal("Cannot connect to database")
}
I used this Dockerfile to adapt mine (that is based on alpine-glibc) in order to install the Spatialite library during image building. According to the Spatialite package, it looks for different for spatialite library and load it.
When checking /usr/local/lib/
in the container, the libraries are there:
libspatialite.a
libspatialite.la
libspatialite.so
libspatialite.so.7
libspatialite.so.7.1.0
libsqlite3.so
libsqlite3.so.0
libsqlite3.so.0.8.6
It seems to me that the program does not know where to get the libraries. Do you have any ideas ?
Thanks