-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
145 lines (120 loc) Β· 4.3 KB
/
Dockerfile
File metadata and controls
145 lines (120 loc) Β· 4.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
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
# SciGo Quick Start Docker Image
# Provides a 30-second ML experience with SciGo
# Build stage
FROM golang:1.23-alpine AS builder
LABEL maintainer="Yuminosuke Sato <yuminosuke.sato@example.com>"
LABEL description="SciGo - The blazing-fast ML library for Go"
LABEL version="0.2.0"
# Install build dependencies
RUN apk add --no-cache git ca-certificates tzdata
# Set working directory
WORKDIR /app
# Copy go mod files first for better layer caching
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the quick start example
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o quick-start ./examples/quick-start
# Build additional examples
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o linear-regression ./examples/linear_regression
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o iris-regression ./examples/iris_regression
# Runtime stage
FROM alpine:latest
# Install runtime dependencies
RUN apk --no-cache add ca-certificates tzdata
# Create non-root user
RUN adduser -D -s /bin/sh -u 1000 scigouser
# Set working directory
WORKDIR /home/scigouser
# Copy built binaries from builder stage
COPY --from=builder /app/quick-start /usr/local/bin/
COPY --from=builder /app/linear-regression /usr/local/bin/
COPY --from=builder /app/iris-regression /usr/local/bin/
# Copy example data and scripts
COPY --from=builder /app/datasets/ ./datasets/
COPY --from=builder /app/examples/ ./examples/
# Create demo script
RUN cat > /usr/local/bin/scigo-demo << 'EOF'
#!/bin/sh
set -e
echo "π Welcome to SciGo Demo!"
echo "========================="
echo ""
echo "Available demos:"
echo "1. Quick Start - Basic linear regression (30 seconds)"
echo "2. Linear Model - Detailed linear regression example"
echo "3. Iris Dataset - Classic ML dataset demonstration"
echo ""
case "${1:-1}" in
1|quick|quick-start)
echo "π― Running Quick Start Demo..."
echo "β±οΈ This should complete in ~30 seconds"
echo ""
time quick-start
;;
2|linear|linear-regression)
echo "π― Running Linear Regression Demo..."
echo ""
time linear-regression
;;
3|iris|iris-regression)
echo "π― Running Iris Dataset Demo..."
echo ""
time iris-regression
;;
all)
echo "π― Running All Demos..."
echo ""
echo "=== Quick Start ==="
time quick-start
echo ""
echo "=== Linear Regression ==="
time linear-regression
echo ""
echo "=== Iris Dataset ==="
time iris-regression
;;
*)
echo "Usage: scigo-demo [1|quick|linear|iris|all]"
echo ""
echo "Examples:"
echo " scigo-demo 1 # Quick start (default)"
echo " scigo-demo quick # Quick start"
echo " scigo-demo linear # Linear regression"
echo " scigo-demo iris # Iris dataset"
echo " scigo-demo all # All demos"
exit 1
;;
esac
echo ""
echo "π Demo completed!"
echo "π Learn more: https://pkg.go.dev/github.com/YuminosukeSato/scigo"
echo "π» Source: https://github.com/YuminosukeSato/scigo"
echo ""
echo "Ready, Set, SciGo! π"
EOF
# Make demo script executable
RUN chmod +x /usr/local/bin/scigo-demo
# Switch to non-root user
USER scigouser
# Add health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD quick-start > /dev/null 2>&1 || exit 1
# Set default command
CMD ["scigo-demo"]
# Add labels for better container management
LABEL org.opencontainers.image.title="SciGo"
LABEL org.opencontainers.image.description="The blazing-fast scikit-learn compatible ML library for Go"
LABEL org.opencontainers.image.version="0.2.0"
LABEL org.opencontainers.image.source="https://github.com/YuminosukeSato/scigo"
LABEL org.opencontainers.image.documentation="https://pkg.go.dev/github.com/YuminosukeSato/scigo"
LABEL org.opencontainers.image.vendor="Yuminosuke Sato"
LABEL org.opencontainers.image.licenses="MIT"
# Expose no ports (this is a demo/CLI container)
# EXPOSE 8080
# Add usage instructions as environment variables
ENV SCIGO_VERSION="0.2.0"
ENV SCIGO_USAGE="Run 'scigo-demo' to see available demonstrations"
ENV SCIGO_DOCS="https://pkg.go.dev/github.com/YuminosukeSato/scigo"
ENV SCIGO_SOURCE="https://github.com/YuminosukeSato/scigo"