Skip to content

Commit b2eec4c

Browse files
committed
feat: Support single node instance persistance and auth
Server changes: * Optional listening on unix domain socket. * Local system root detection and auto authentication on UDS connection. * TLS support. tigris_server2 is started with TLS and tests are run through TLS on it. Due to cmux limitations it can only be routed to HTTP or GRPC, so there is an option added to control this `server.tls_http` * Test server configs moved to `test/config/server.{test,test2}.yaml` Teste secrets move to `test/config/keys/*`. Single node instance improvement made as part of `tigrisdata/tigris-local` container. The service is configured and started using `scripts/service-local.sh` in the container. The follwing configuration available: * TIGRIS_BOOTSTRAP_LOCAL_AUTH - initialize authentication on first instance start. It creates necessary tokens, users, namespaces for server <-> gotrue interconnection. * TIGRIS_LOCAL_PERSISTENCE initializes FDB in ssd mode vs memory. * TIGRIS_LOCAL_GENERATE_ADMIN_TOKEN produces admin user token in the data directory (./user_admin_token.txt). This not necessary on unix compatible system, where we can detect container owner by peer. * TIGRIS_SKIP_LOCAL_AUTH allows to temporary disable authenticaion on already initialized system. * TIGRIS_LOCAL_DEBUG can be set to enable debug logging in `./init.log` Bootstrap can only be initiated if the data directory is empty, it's noop otherwise. ``` docker run -e TIGRIS_BOOTSTRAP_LOCAL_AUTH=1 \ -e TIGRIS_LOCAL_PERSISTENCE=1 \ -e TIGRIS_LOCAL_GENERATE_ADMIN_TOKEN=1 \ --name my-tigris -v $TMPDIR:/var/lib/tigris \ -d -p $HOST_PORT:8081 tigrisdata/tigris-local ``` This is the structure of the persistence volume: ``` /var/lib/tigris/ ├── foundationdb │   ├── data │   │   ├── coordination-0.fdq │   │   ├── coordination-1.fdq │   │   ├── log2-V_6-3c801d05cd47c75a120e968dce9187a9.sqlite │   │   ├── log2-V_6-3c801d05cd47c75a120e968dce9187a9.sqlite-wal │   │   ├── logqueue-V_6-3c801d05cd47c75a120e968dce9187a9-0.fdq │   │   ├── processId │   │   ├── storage-1b4c5b99aff541f54264fa55e20b84b3.sqlite │   │   └── storage-1b4c5b99aff541f54264fa55e20b84b3.sqlite-wal │   └── logs │   └── trace.127.0.0.1.4500.1685517319.uq6Q1t.1.31.xml ├── gotrue │   ├── config │   │   ├── key │   │   ├── key_pem.pub │   │   └── key.pub │   ├── data │   └── logs │   ├── stderr │   └── stdout ├── initialized ├── init.log ├── server │   ├── config │   │   └── server.yaml │   ├── data │   ├── logs │   │   ├── stderr │   │   └── stdout │   └── unix.sock ├── typesense │   ├── config │   │   └── typesense-server.ini │   ├── data │   │   ├── db │   │   │   ├── 000234.log │   │   │   ├── 000236.sst │   │   │   ├── archive │   │   │   │   ├── 000005.log │   │   │   │   └── 000232.log │   │   │   ├── CURRENT │   │   │   ├── IDENTITY │   │   │   ├── LOCK │   │   │   ├── LOG │   │   │   ├── MANIFEST-000004 │   │   │   └── OPTIONS-000007 │   │   ├── meta │   │   │   ├── 000015.log │   │   │   ├── archive │   │   │   ├── CURRENT │   │   │   ├── IDENTITY │   │   │   ├── LOCK │   │   │   ├── LOG │   │   │   ├── LOG.old.1685517292544545 │   │   │   ├── LOG.old.1685517319188484 │   │   │   ├── MANIFEST-000014 │   │   │   ├── OPTIONS-000012 │   │   │   └── OPTIONS-000017 │   │   └── state │   │   ├── log │   │   │   ├── log_inprogress_00000000000000000001 │   │   │   └── log_meta │   │   ├── meta │   │   │   └── raft_meta │   │   └── snapshot │   │   └── snapshot_00000000000000000482 │   │   ├── db_snapshot │   │   │   ├── 000231.sst │   │   │   ├── CURRENT │   │   │   ├── MANIFEST-000004 │   │   │   └── OPTIONS-000007 │   │   └── __raft_snapshot_meta │   └── logs │   └── typesense.log └── user_admin_token.txt ```
1 parent ca2e6e5 commit b2eec4c

40 files changed

+1309
-255
lines changed

.github/workflows/test-docker-local-image.yaml

+3-17
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ on:
66
- docker/Dockerfile.local
77
- scripts/install_local_deps.sh
88
- .github/workflows/test-docker-local-image.yaml
9-
merge_group:
10-
paths:
11-
- docker/Dockerfile.local
12-
- scripts/install_local_deps.sh
13-
- .github/workflows/test-docker-local-image.yaml
9+
- scripts/test_docker_local.sh
1410
push:
1511
branches:
1612
- main
@@ -24,15 +20,5 @@ jobs:
2420
with:
2521
submodules: true
2622

27-
- name: Build local image
28-
run: make docker-local
29-
30-
- name: Run local image
31-
run: docker run -d -p 8081:8081 tigris_local
32-
33-
- name: Run CLI tests
34-
run: |
35-
curl -sSL https://tigris.dev/cli-linux | tar -xz -C .
36-
TIGRIS_URL=localhost:8081 ./tigris ping --timeout 20s
37-
TIGRIS_TEST_PORT=8081 TIGRIS_CLI_TEST_FAST=1 noup=1 /bin/bash test/v1/cli/main.sh
38-
23+
- name: Run tests
24+
run: SUDO=sudo /bin/bash scripts/test_docker_local.sh

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ local_test: generate lint
5858
local_run: server
5959
$(DOCKER_COMPOSE) up --no-build --detach tigris_search tigris_db2 tigris_cache
6060
fdbcli -C ./test/config/fdb.cluster --exec "configure new single memory" || true
61-
./server/service -c config/server.dev.yaml
61+
./server/service -c test/config/server.dev.yaml
6262

6363
# Start local instance with server running on the host in realtime mode.
6464
# This is useful for debugging the server. The process is attachable from IDE.

docker/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ RUN groupadd -r tigris && useradd -r -s /bin/false -g tigris tigris
4141
RUN mkdir -p /server /etc/tigrisdata/tigris /etc/foundationdb/
4242

4343
ARG BUILD_PROFILE=""
44+
ARG CONF_PATH=""
4445

4546
COPY --from=build /build/server/service /server/service
46-
COPY --from=build /build/config/server${BUILD_PROFILE}.yaml /etc/tigrisdata/tigris
47+
COPY --from=build /build/${CONF_PATH}config/server${BUILD_PROFILE}.yaml /etc/tigrisdata/tigris
4748
COPY --from=build /usr/lib/libfdb_c.so /usr/lib/libfdb_c.so
4849
COPY --from=build /usr/bin/fdbcli /usr/bin/fdbcli
4950

docker/Dockerfile.local

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ RUN go mod download
2020
COPY . /build
2121
RUN --mount=type=cache,target=/root/.cache/go-build rm -f server/service && make bins
2222

23+
RUN go install -tags tigris_http,tigris_grpc -ldflags "-w -s" github.com/tigrisdata/gotrue@latest
24+
2325
FROM ubuntu:20.04 AS server
2426

2527
RUN apt-get update && \
2628
apt-get install -y --no-install-recommends \
27-
ca-certificates \
29+
ca-certificates openssh-client jq \
2830
curl && apt-get clean
2931

3032
COPY scripts/install_local_docker_deps.sh /tmp/
@@ -35,15 +37,16 @@ RUN rm -rf /etc/apt/* /var/lib/dpkg/* /var/lib/apt/*
3537
# Setup an unprivileged user
3638
RUN groupadd -r tigris && useradd -r -s /bin/false -g tigris tigris
3739

38-
RUN mkdir -p /server /etc/tigrisdata/tigris /etc/foundationdb /var/lib/foundationdb/logs
40+
RUN mkdir -p /server /etc/tigrisdata/tigris
3941

4042
COPY --from=build /build/server/service /server/service
4143
COPY --from=build /build/config/server.yaml /etc/tigrisdata/tigris
4244
COPY --from=build /usr/lib/libfdb_c.so /usr/lib/libfdb_c.so
4345
COPY --from=build /usr/bin/fdbcli /usr/bin/fdbcli
46+
COPY --from=build /root/go/bin/gotrue /usr/bin/gotrue
4447

4548
RUN chown -R tigris:tigris /server /etc/tigrisdata/tigris
46-
COPY docker/service-local.sh /server/service.sh
49+
COPY scripts/service-local.sh /server/service.sh
4750

4851
EXPOSE 8081
4952

docker/service-local.sh

-61
This file was deleted.

scripts/install_local_docker_deps.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
1716
set -ex
1817

18+
D=/var/lib/tigris
19+
1920
ARCH=$(dpkg --print-architecture)
2021

2122
case "${ARCH}" in
@@ -69,5 +70,7 @@ curl --create-dirs -Lo "$TS_PACKAGE_PATH" "https://dl.typesense.org/releases/${T
6970
dpkg --unpack "$TS_PACKAGE_PATH"
7071
rm -f /var/lib/dpkg/info/typesense-server.postinst
7172
dpkg --configure typesense-server
72-
sed -i "s/\$API_KEY/ts_dev_key/g" /etc/typesense/typesense-server.ini && \
73-
rm -f "$TS_PACKAGE_PATH"
73+
rm -rf /var/lib/typesense /etc/typesense
74+
75+
mkdir $D
76+

0 commit comments

Comments
 (0)