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:
+5
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user