-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
91 lines (69 loc) · 2.95 KB
/
Copy pathDockerfile
File metadata and controls
91 lines (69 loc) · 2.95 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
# Dockerfile
# Build stage
FROM golang:1.26-alpine@sha256:28d89ee9cc0ff9fec75c82ca201e6bf7fdf9a679d4b7b24dfa04f2bb766bb468 AS builder
# Install build dependencies
RUN apk add --no-cache git make ca-certificates tzdata gcc musl-dev sqlite-dev npm nodejs
# Set working directory
WORKDIR /build
# Clone the langchaingo fork first
RUN git clone --depth 1 https://github.com/lonelycode/langchaingo /build/langchaingo
# Copy go.mod files first for better caching
COPY go.mod go.sum ./
COPY microgateway/go.mod microgateway/go.sum ./microgateway/
# Copy all source code
COPY . .
# Fix the replace directives to use the cloned langchaingo
RUN sed -i 's|replace github.com/tmc/langchaingo => /Users/martinbuhr/apps/lonelycode/langchaingo|replace github.com/tmc/langchaingo => /build/langchaingo|g' go.mod && \
sed -i 's|replace github.com/tmc/langchaingo => /Users/martinbuhr/apps/lonelycode/langchaingo|replace github.com/tmc/langchaingo => /build/langchaingo|g' microgateway/go.mod
# Build frontend
RUN cd ui/admin-frontend && npm ci --ignore-scripts && PUBLIC_URL="/" REACT_APP_API_URL="" CI=false npm run build
# Build documentation site
RUN cd docs/site && npm ci --ignore-scripts && npm run docs:build
# Build arguments for version information and edition
ARG EDITION=ce
# Remove enterprise module references for CE builds
RUN if [ "$EDITION" = "ce" ]; then \
sed -i '/github.com\/TykTechnologies\/midsommar\/v2\/enterprise/d' go.mod; \
sed -i '/github.com\/TykTechnologies\/midsommar\/v2\/enterprise/d' microgateway/go.mod; \
fi
# Download dependencies
RUN go mod download
ARG VERSION=dev
ARG BUILD_HASH=unknown
ARG BUILD_TIME=unknown
# Build the binary
RUN if [ "$EDITION" = "ent" ]; then \
BUILD_TAGS="-tags enterprise"; \
else \
BUILD_TAGS=""; \
fi && \
echo "Building tyk-ai-studio $EDITION edition with tags: $BUILD_TAGS" && \
CGO_ENABLED=1 go build \
$BUILD_TAGS \
-ldflags="-w -s -X main.Version=${VERSION} -X main.BuildHash=${BUILD_HASH} -X main.BuildTime=${BUILD_TIME}" \
-trimpath \
-o tyk-ai-studio \
.
# Runtime stage
FROM alpine:3.21@sha256:c3f8e73fdb79deaebaa2037150150191b9dcbfba68b4a46d70103204c53f4709
RUN apk add --no-cache \
ca-certificates \
sqlite-libs \
poppler-utils \
wget && \
# Install cosign for OCI plugin signature verification (Enterprise)
COSIGN_VERSION=2.4.1 && \
ARCH=$(uname -m | sed 's/aarch64/arm64/' | sed 's/x86_64/amd64/') && \
wget -q "https://github.com/sigstore/cosign/releases/download/v${COSIGN_VERSION}/cosign-linux-${ARCH}" -O /usr/local/bin/cosign && \
chmod +x /usr/local/bin/cosign
WORKDIR /app
# Copy binary from builder
COPY --from=builder /build/tyk-ai-studio ./tyk-ai-studio
# Copy templates directory
COPY templates ./templates
# Copy docs_links.json file
COPY config/docs_links.json ./config/docs_links.json
# Expose the required ports
EXPOSE 8080 9090 50051
# Run the binary directly
ENTRYPOINT ["./tyk-ai-studio"]