-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathDockerfile-Stream-Log
More file actions
61 lines (44 loc) · 1.3 KB
/
Dockerfile-Stream-Log
File metadata and controls
61 lines (44 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -----------------------------
# Builder Stage
# -----------------------------
FROM golang:1.25.0 AS builder
ENV CGO_ENABLED=1
ENV GOOS=linux
ENV GOARCH=amd64
# Optional: copy common packages if used
RUN mkdir /common
COPY services/common /common
# Set working directory
WORKDIR /app
# Copy Go module files first for caching
COPY services/log_stream/go.mod services/log_stream/go.sum ./
RUN go mod download
# Copy the rest of the source
COPY services/log_stream .
# Build the binary with optional size optimization
RUN go build -ldflags="-s -w" -o log_stream main.go
# -----------------------------
# Final Stage
# -----------------------------
FROM debian:trixie-slim
# Install runtime dependencies only
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
sqlite3 \
libsqlite3-dev && \
rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy the Go binary from the builder stage
COPY --from=builder /app/log_stream /usr/local/bin/log_stream
COPY services/log_stream/scripts/server.sh /server.sh
RUN chmod +x /server.sh
# Make binary executable
RUN chmod +x /usr/local/bin/log_stream
# Set up volume for database persistence
VOLUME ["/usr/local/bin/db"]
# Expose application port
EXPOSE 8080
# Default command
CMD ["/server.sh"]