mirror of
https://github.com/rqlite/rqlite.git
synced 2026-01-25 04:16:26 +00:00
88 lines
3.0 KiB
Docker
88 lines
3.0 KiB
Docker
FROM golang:alpine AS builder
|
|
|
|
ARG VERSION="unknown"
|
|
ARG COMMIT="unknown"
|
|
ARG BRANCH="unknown"
|
|
ARG DATE="unknown"
|
|
|
|
RUN apk add --no-cache \
|
|
curl \
|
|
gcc \
|
|
gettext \
|
|
git \
|
|
icu-dev \
|
|
linux-headers \
|
|
make \
|
|
musl-dev \
|
|
pkgconf \
|
|
zlib-dev \
|
|
zip
|
|
|
|
COPY . /app
|
|
|
|
# Build rqlite.
|
|
WORKDIR /app
|
|
ENV CGO_ENABLED=1
|
|
RUN go build -ldflags=" \
|
|
-w -s -X github.com/rqlite/rqlite/v9/cmd.CompilerCommand=musl-gcc \
|
|
-X github.com/rqlite/rqlite/v9/cmd.Version=${VERSION} \
|
|
-X github.com/rqlite/rqlite/v9/cmd.Branch=${BRANCH} \
|
|
-X github.com/rqlite/rqlite/v9/cmd.Commit=${COMMIT} \
|
|
-X github.com/rqlite/rqlite/v9/cmd.Buildtime=${DATE}" ./cmd/rqlited/. && \
|
|
go build -ldflags="-w -s" ./cmd/rqlite/.
|
|
|
|
# Build the extensions, start by creating the extensions directory.
|
|
WORKDIR /extensions
|
|
WORKDIR /app
|
|
|
|
RUN curl -L `curl -s https://api.github.com/repos/nalgeon/sqlean/releases/latest | grep "tarball_url" | cut -d '"' -f 4` -o sqlean.tar.gz && \
|
|
tar xvfz sqlean.tar.gz && \
|
|
cd nalgeon* && make prepare-dist download-sqlite download-external compile-linux && zip -j /extensions/sqlean.zip dist/sqlean.so
|
|
|
|
RUN curl -L `curl -s https://api.github.com/repos/asg017/sqlite-vec/releases/latest | grep "tarball_url" | cut -d '"' -f 4` -o sqlite-vec.tar.gz && \
|
|
tar xvfz sqlite-vec.tar.gz && \
|
|
echo location >> ~/.curlrc && \
|
|
cd asg017* && sh scripts/vendor.sh && echo "#include <sys/types.h>" | cat - sqlite-vec.c > temp && mv temp sqlite-vec.c && make loadable && zip -j /extensions/sqlite-vec.zip dist/vec0.so
|
|
|
|
RUN curl -L `curl -s https://api.github.com/repos/sqliteai/sqlite-vector/releases/latest | grep "tarball_url" | cut -d '"' -f 4` -o sqliteai-vector.tar.gz && \
|
|
tar xvfz sqliteai-vector.tar.gz && rm sqliteai-vector.tar.gz && \
|
|
cd sqliteai* && make && zip -j /extensions/sqliteai-vector.zip dist/vector.so
|
|
|
|
RUN git clone https://github.com/rqlite/rqlite-sqlite-ext.git
|
|
RUN cd rqlite-sqlite-ext/misc && make && zip /extensions/misc.zip *.so
|
|
RUN cd rqlite-sqlite-ext/icu && gcc -fPIC -shared icu.c -I .. `pkg-config --libs --cflags icu-uc icu-io` -o icu.so && zip /extensions/icu.zip icu.so
|
|
|
|
#######################################################################
|
|
# Phase 2: Create the final image.
|
|
FROM alpine:latest
|
|
|
|
RUN apk add --no-cache icu-libs
|
|
|
|
# Create the user and group (Alpine syntax).
|
|
# Using 1000 is standard convention for non-root users.
|
|
RUN addgroup -g 1000 rqlite && \
|
|
adduser -u 1000 -G rqlite -D rqlite
|
|
|
|
# Copy the init script and rqlite binaries.
|
|
COPY --from=builder /app/docker-entrypoint.sh /bin
|
|
COPY --from=builder /app/rqlited /bin
|
|
COPY --from=builder /app/rqlite /bin
|
|
|
|
# Bake in the extensions.
|
|
COPY --from=builder /extensions /opt/extensions/
|
|
|
|
# Create the directory and fix ownership permissions.
|
|
# This ensures the 'rqlite' user can write to this directory.
|
|
RUN mkdir -p /rqlite/file && \
|
|
chown -R rqlite:rqlite /rqlite/file
|
|
|
|
VOLUME /rqlite/file
|
|
|
|
EXPOSE 4001 4002
|
|
|
|
# Switch to the non-root user.
|
|
USER rqlite
|
|
|
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
|
CMD ["run"]
|