Skip to content

Commit 5c0625a

Browse files
committed
add docker image
1 parent 91aaf1b commit 5c0625a

6 files changed

Lines changed: 109 additions & 1 deletion

File tree

.dockerignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.git
2+
.gitmodules
3+
data
4+
mydata
5+
logs
6+
*.exe
7+
*.ini
8+
*.log
9+
*.test
10+
homepage
11+
admin
12+
benchmark
13+
drivers
14+
tools
15+
testdata
16+
docs
17+
coverage
18+
coverage.html
19+
node_modules
20+
.next
21+
.venv
22+
__pycache__
23+
*.pyc
24+
.env

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Build stage
2+
FROM golang:1.24-alpine AS builder
3+
4+
RUN apk add --no-cache git
5+
6+
WORKDIR /app
7+
COPY go.mod go.sum ./
8+
RUN go mod download
9+
10+
COPY . .
11+
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -trimpath -o /gtsdb .
12+
13+
# Runtime stage
14+
FROM alpine:3.21
15+
16+
RUN apk add --no-cache ca-certificates tzdata
17+
18+
COPY docker-entrypoint.sh /docker-entrypoint.sh
19+
RUN chmod +x /docker-entrypoint.sh
20+
21+
COPY --from=builder /gtsdb /usr/local/bin/gtsdb
22+
23+
RUN mkdir -p /data /etc/gtsdb
24+
25+
EXPOSE 5555 5556
26+
27+
VOLUME ["/data"]
28+
29+
ENTRYPOINT ["/docker-entrypoint.sh"]

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<a href="./docs/coverage-full.svg"><img alt="Coverage" src="./docs/coverage.svg" /></a>
1010
<a href="https://gtsdb-admin.vercel.app/"><img alt="Admin Tool" src="https://img.shields.io/badge/admin%20tool-demo-blue" /></a>
1111
<a href="https://github.com/abbychau/gtsdb/releases"><img alt="Release" src="https://img.shields.io/github/v/release/abbychau/gtsdb" /></a>
12+
<a href="https://hub.docker.com/r/abbychau/gtsdb"><img alt="Docker" src="https://img.shields.io/badge/docker-abbychau%2Fgtsdb-blue?logo=docker" /></a>
1213
</p>
1314

1415
A simple, high-performance timeseries database for IoT and edge computing. **HTTP + TCP**, **sub-millisecond reads**, **233× faster than InfluxDB on writes**, **Gorilla compression**.

docker-compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
services:
2+
gtsdb:
3+
image: abbychau/gtsdb:latest
4+
container_name: gtsdb
5+
ports:
6+
- "5555:5555" # TCP
7+
- "5556:5556" # HTTP
8+
volumes:
9+
- gtsdb_data:/data
10+
environment:
11+
- GTSDB_TCP_ADDR=0.0.0.0:5555
12+
- GTSDB_HTTP_ADDR=0.0.0.0:5556
13+
- GTSDB_DATA_DIR=/data
14+
- GTSDB_CACHE_SIZE=10000
15+
- GTSDB_SYNC_MODE=async
16+
- GTSDB_COMPRESSION=true
17+
# - GTSDB_NO_AUTH_USER=root # uncomment to skip auth
18+
# - GTSDB_ROOT_TOKEN=secret # uncomment to set root token
19+
restart: unless-stopped
20+
21+
volumes:
22+
gtsdb_data:

docker-entrypoint.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
# Generate gtsdb.ini from environment variables
3+
4+
CONFIG="/etc/gtsdb/gtsdb.ini"
5+
mkdir -p /etc/gtsdb
6+
7+
cat > "$CONFIG" << EOF
8+
[paths]
9+
data = ${GTSDB_DATA_DIR:-/data}
10+
11+
[listens]
12+
http = ${GTSDB_HTTP_ADDR:-0.0.0.0:5556}
13+
tcp = ${GTSDB_TCP_ADDR:-0.0.0.0:5555}
14+
15+
[buffer]
16+
file_handle_lru_capacity = 700
17+
compaction_compression = ${GTSDB_COMPRESSION:-true}
18+
sync_mode = ${GTSDB_SYNC_MODE:-async}
19+
sync_interval_ms = ${GTSDB_SYNC_INTERVAL_MS:-1000}
20+
cache_size = ${GTSDB_CACHE_SIZE:-10000}
21+
22+
[auth]
23+
EOF
24+
25+
if [ -n "$GTSDB_NO_AUTH_USER" ]; then
26+
echo "no_auth_user = $GTSDB_NO_AUTH_USER" >> "$CONFIG"
27+
fi
28+
if [ -n "$GTSDB_ROOT_TOKEN" ]; then
29+
echo "root_token = $GTSDB_ROOT_TOKEN" >> "$CONFIG"
30+
fi
31+
32+
exec /usr/local/bin/gtsdb "$CONFIG"

homepage

0 commit comments

Comments
 (0)