Open armyja opened 2 months ago
+1
@wjkoh can you try with the just released v0.1.3-alpha.1
? I believe I fixed the sqlite3ext.h
with that one, and the "undefined symbol sqrtf" error should also be fixed.
@asg017 It works! After upgrading to v0.1.3-alpha.1
, I was able to build a binary with the system-wide libsqlite3 without a problem. See the Dockerfile at the end.
One caveat is the golang:1.23
image uses Debian Bookworm as the base image and it has SQLite 3.40.1-2, which doesn't have JSONB support. That's the only drawback. Also, if you use a multi-stage build, don't forget to copy libsqlite3.so.0
from the builder image to the final image.
FROM golang:1.23 as builder
ENV CGO_ENABLED=1
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive \
apt-get install --no-install-recommends --assume-yes \
libsqlite3-dev
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN go build -tags libsqlite3 -o server ./cmd/vino
@wjkoh you can get around this by installing libsqlite3-dev
from trixie instead, which gives you SQLite 3.46.0 at the time of writing:
FROM golang
WORKDIR /src
RUN echo "deb http://deb.debian.org/debian trixie main" >>/etc/apt/sources.list
RUN set -x && apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y libsqlite3-dev/trixie
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
ARG TARGETARCH
RUN GOOS=linux GOARCH=${TARGETARCH} CGO_ENABLED=1 go build -tags fts5,libsqlite3 -buildvcs=false -ldflags="-s -w" -o /bin/api ./cmd/api
To solve the compilation error, I have to add environment variable:
Are there any simpler alternatives?