-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
159 lines (111 loc) · 3.81 KB
/
Copy pathDockerfile
File metadata and controls
159 lines (111 loc) · 3.81 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Multi-stage Dockerfile for development, testing, and production
# Build stage - optimized for smaller size
FROM golang:1.25.5-alpine3.23 AS builder
WORKDIR /app
# Install build dependencies if needed
# RUN apk add --no-cache git
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY . .
# Build the binary with optimizations
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build \
-ldflags="-s -w -buildid=" \
-trimpath \
-o stackyrd ./cmd/app
# Test stage
FROM builder AS test
# Run tests
RUN go test ./...
# Production stage (Alpine - ~50MB, Python plugin support)
FROM alpine:3.23 AS prod
# Install ca-certificates for HTTPS and Python 3 for external (Python) plugins
RUN apk --no-cache add ca-certificates python3 py3-pip && \
pip3 install --no-cache-dir grpcio protobuf
WORKDIR /root/
# Copy the binary from builder stage
COPY --from=builder /app/stackyrd .
# Copy config
COPY --from=builder /app/config.yaml .
# Copy Python plugin host scripts (for external/ext: plugins)
COPY --from=builder /app/pkg/plugin/python ./pkg/plugin/python/
# Create plugin store directory for writable overlay (uploaded scripts, etc.)
RUN mkdir -p store/plugins
# Configure for Docker environment
ENV APP_QUIET_STARTUP=false
ENV APP_ENABLE_TUI=false
# Expose ports for main API server
EXPOSE 8080
# Run the application
CMD ["./stackyrd", "-env", "production"]
# Slim production stage (Ubuntu minimal - ~40MB, Python plugin support)
FROM ubuntu:24.04 AS prod-slim
WORKDIR /root/
# Install minimal runtime dependencies and Python 3 for external plugins
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
python3 \
python3-pip \
python3-venv \
&& pip3 install --no-cache-dir grpcio protobuf \
&& rm -rf /var/lib/apt/lists/*
# Copy the binary from builder stage
COPY --from=builder /app/stackyrd .
# Copy config
COPY --from=builder /app/config.yaml .
# Copy Python plugin host scripts (for external/ext: plugins)
COPY --from=builder /app/pkg/plugin/python ./pkg/plugin/python/
# Create plugin store directory for writable overlay
RUN mkdir -p store/plugins
# Configure for Docker environment
ENV APP_QUIET_STARTUP=false
ENV APP_ENABLE_TUI=false
# Expose ports for main API server
EXPOSE 8080
# Run the application
CMD ["./stackyrd", "-env", "production"]
# Minimal production stage (Distroless - ultra-minimal, TS/Go plugins only)
# NOTE: Python/external (ext:) plugins are not supported in this stage
# because distroless/static does not include a Python runtime.
# TypeScript (ts:) and Go (go:) plugins work fine (compiled into binary).
FROM gcr.io/distroless/static:nonroot AS prod-distroless
WORKDIR /
# Copy the binary from builder stage
COPY --from=builder /app/stackyrd /stackyrd
# Copy config
COPY --from=builder /app/config.yaml .
# Copy Python host scripts (in case Python is layered on top)
COPY --from=builder /app/pkg/plugin/python /pkg/plugin/python/
# Configure for Docker environment
ENV APP_QUIET_STARTUP=false
ENV APP_ENABLE_TUI=false
# Expose ports for main API server
EXPOSE 8080
# Run the application
CMD ["/stackyrd", "-env", "production"]
# Development stage (full toolchain + Python plugin support)
FROM golang:1.25.5-alpine3.23 AS dev
WORKDIR /app
# Install Python 3 for external plugin development
RUN apk --no-cache add python3 py3-pip && \
pip3 install --no-cache-dir grpcio protobuf
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY . .
# Build the binary
RUN go build -o stackyrd ./cmd/app
# Create plugin store directory
RUN mkdir -p store/plugins
# Configure for Docker environment
ENV APP_QUIET_STARTUP=false
ENV APP_ENABLE_TUI=false
# Expose ports for main API server
EXPOSE 8080
# Run the application
CMD ["./stackyrd", "-env", "development"]