feat: enhance Dockerfile for SQLite support and update main.go for MySQL connection; add sensor creation endpoint and improve wait-for-mqtt script

This commit is contained in:
2026-01-10 14:20:38 +01:00
parent a6196cc0ee
commit 81677943c4
5 changed files with 89 additions and 35 deletions
+5 -2
View File
@@ -2,16 +2,19 @@
FROM golang:1.21-alpine AS builder
WORKDIR /src
# sqlite3 driver requires CGO; install build deps
RUN apk add --no-cache build-base sqlite-dev
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \
go build -ldflags "-s -w" -o /app/server ./cmd/server
# Final image
FROM alpine:3.18
RUN apk add --no-cache ca-certificates netcat-openbsd curl
RUN apk add --no-cache ca-certificates netcat-openbsd curl sqlite-libs
COPY --from=builder /app/server /usr/local/bin/server
COPY scripts/wait-for-mqtt.sh /usr/local/bin/wait-for-mqtt.sh
RUN chmod +x /usr/local/bin/wait-for-mqtt.sh