-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (38 loc) · 1.64 KB
/
Copy pathDockerfile
File metadata and controls
47 lines (38 loc) · 1.64 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
# ==============================================================================
# Stage 1: Build AOT-compiled binaries
# ==============================================================================
FROM dart:stable AS build
WORKDIR /app
# Cache dependencies
COPY pubspec.yaml ./
RUN dart pub get --no-example
# Copy source and compile
COPY lib/ lib/
COPY bin/ bin/
RUN dart compile exe bin/generate.dart -o /app/bin/generate && \
dart compile exe bin/localize.dart -o /app/bin/localize
# Collect runtime dependencies (glibc, ld-linux, etc.)
RUN mkdir -p /runtime/lib /runtime/lib64 && \
# Use ldd to find all shared libraries needed by compiled binaries
(ldd /app/bin/generate /app/bin/localize || true) \
| grep -oP '(?<==> )\S+' | sort -u | while read lib; do \
dir="/runtime$(dirname "$lib")"; \
mkdir -p "$dir"; \
cp "$lib" "$dir/"; \
done && \
# Copy the dynamic linker
cp /lib64/ld-linux-* /runtime/lib64/ 2>/dev/null || \
cp /lib/ld-linux-* /runtime/lib/ 2>/dev/null || true
# ==============================================================================
# Stage 2: Minimal scratch image
# ==============================================================================
FROM scratch
# CA certificates for HTTPS (Google Sheets API, OpenAI API)
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
# Runtime libraries (glibc, ld-linux)
COPY --from=build /runtime/ /
# Compiled binaries
COPY --from=build /app/bin/generate /bin/generate
COPY --from=build /app/bin/localize /bin/localize
ENTRYPOINT ["/bin/generate"]