-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
229 lines (194 loc) · 7.52 KB
/
Copy pathDockerfile
File metadata and controls
229 lines (194 loc) · 7.52 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
## ---------------------------------------------------------------------------
## Core: flutter_map_sld
## ---------------------------------------------------------------------------
FROM dart:stable AS base
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
lcov \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy only pubspec first for dependency caching
COPY packages/flutter_map_sld/pubspec.yaml packages/flutter_map_sld/pubspec.yaml
WORKDIR /app/packages/flutter_map_sld
# Strip workspace resolution for isolated Docker build
RUN sed -i '/^resolution: workspace$/d' pubspec.yaml
RUN dart pub get
# Copy the rest of the package, then re-strip (COPY overwrites the sed'd pubspec)
COPY packages/flutter_map_sld/ /app/packages/flutter_map_sld/
RUN sed -i '/^resolution: workspace$/d' pubspec.yaml
# Analyze
FROM base AS analyze
RUN dart analyze
# Test
FROM base AS test
RUN dart test
# Coverage report.
FROM base AS coverage
ARG COVERAGE_VERSION=1.15.0
RUN dart pub global activate coverage ${COVERAGE_VERSION}
ENV PATH="/root/.pub-cache/bin:${PATH}"
RUN dart test --coverage=coverage
RUN dart pub global run coverage:format_coverage \
--packages=.dart_tool/package_config.json \
--report-on=lib \
--lcov \
--in=coverage \
--out=coverage/lcov.info
RUN lcov --summary coverage/lcov.info
# Coverage threshold check.
FROM coverage AS coverage-check
ARG COVERAGE_MIN=95
RUN awk -F'[,:]' -v min="$COVERAGE_MIN" '\
/^DA:/ { total += 1; if ($3 > 0) hit += 1 } \
END { \
if (total == 0) { \
print "No coverage data found in coverage/lcov.info"; \
exit 1; \
} \
pct = (hit / total) * 100; \
printf "Line coverage: %.2f%% (threshold %.2f%%)\n", pct, min; \
if (pct < min) { exit 2 } \
}' coverage/lcov.info
# Doc — generate API documentation into doc/api/.
#
# Generate + extract:
# docker build --target doc -t flutter_map_sld:doc .
# docker run --rm flutter_map_sld:doc | tar -xzf -
FROM base AS doc
RUN dart doc
RUN test -f doc/api/index.html && echo "API docs generated: $(find doc/api -name '*.html' | wc -l) HTML files"
RUN tar -czf /doc-api.tar.gz doc/api
ENTRYPOINT ["cat", "/doc-api.tar.gz"]
# Publish dry-run
FROM base AS publish-check
RUN dart pub publish --dry-run
## ---------------------------------------------------------------------------
## IO: flutter_map_sld_io
## ---------------------------------------------------------------------------
FROM dart:stable AS io-base
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
lcov \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy core package (dependency) and strip workspace resolution
COPY packages/flutter_map_sld/pubspec.yaml packages/flutter_map_sld/pubspec.yaml
RUN sed -i '/^resolution: workspace$/d' packages/flutter_map_sld/pubspec.yaml
COPY packages/flutter_map_sld/lib/ packages/flutter_map_sld/lib/
# Copy IO package pubspec first for dependency caching
COPY packages/flutter_map_sld_io/pubspec.yaml packages/flutter_map_sld_io/pubspec.yaml
WORKDIR /app/packages/flutter_map_sld_io
# Strip workspace resolution and add local path override
RUN sed -i '/^resolution: workspace$/d' pubspec.yaml
RUN printf 'dependency_overrides:\n flutter_map_sld:\n path: ../flutter_map_sld\n' > pubspec_overrides.yaml
RUN dart pub get
# Copy the rest of the IO package, then re-strip
COPY packages/flutter_map_sld_io/ /app/packages/flutter_map_sld_io/
RUN sed -i '/^resolution: workspace$/d' pubspec.yaml
# Analyze
FROM io-base AS io-analyze
RUN dart analyze
# Test
FROM io-base AS io-test
RUN dart test
# Coverage report.
FROM io-base AS io-coverage
ARG COVERAGE_VERSION=1.15.0
RUN dart pub global activate coverage ${COVERAGE_VERSION}
ENV PATH="/root/.pub-cache/bin:${PATH}"
RUN dart test --coverage=coverage
RUN dart pub global run coverage:format_coverage \
--packages=.dart_tool/package_config.json \
--report-on=lib \
--lcov \
--in=coverage \
--out=coverage/lcov.info
RUN lcov --summary coverage/lcov.info
# Coverage threshold check.
FROM io-coverage AS io-coverage-check
ARG COVERAGE_MIN=95
RUN awk -F'[,:]' -v min="$COVERAGE_MIN" '\
/^DA:/ { total += 1; if ($3 > 0) hit += 1 } \
END { \
if (total == 0) { \
print "No coverage data found in coverage/lcov.info"; \
exit 1; \
} \
pct = (hit / total) * 100; \
printf "Line coverage: %.2f%% (threshold %.2f%%)\n", pct, min; \
if (pct < min) { exit 2 } \
}' coverage/lcov.info
# Doc — generate API documentation.
#
# Generate + extract:
# docker build --target io-doc -t flutter_map_sld_io:doc .
# docker run --rm flutter_map_sld_io:doc | tar -xzf -
FROM io-base AS io-doc
RUN dart doc
RUN test -f doc/api/index.html && echo "API docs generated: $(find doc/api -name '*.html' | wc -l) HTML files"
RUN tar -czf /doc-api.tar.gz doc/api
ENTRYPOINT ["cat", "/doc-api.tar.gz"]
# Publish dry-run
FROM io-base AS io-publish-check
RUN dart pub publish --dry-run
## ---------------------------------------------------------------------------
## Flutter Adapter: flutter_map_sld_flutter_map
## ---------------------------------------------------------------------------
FROM ghcr.io/cirruslabs/flutter:stable AS flutter-map-base
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
lcov \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy core package (dependency) and strip workspace resolution
COPY packages/flutter_map_sld/pubspec.yaml packages/flutter_map_sld/pubspec.yaml
RUN sed -i '/^resolution: workspace$/d' packages/flutter_map_sld/pubspec.yaml
COPY packages/flutter_map_sld/lib/ packages/flutter_map_sld/lib/
# Copy Flutter adapter package pubspec first for dependency caching
COPY packages/flutter_map_sld_flutter_map/pubspec.yaml packages/flutter_map_sld_flutter_map/pubspec.yaml
WORKDIR /app/packages/flutter_map_sld_flutter_map
# Strip workspace resolution and add local path override
RUN sed -i '/^resolution: workspace$/d' pubspec.yaml
RUN printf 'dependency_overrides:\n flutter_map_sld:\n path: ../flutter_map_sld\n' > pubspec_overrides.yaml
RUN flutter pub get
# Copy the rest of the Flutter adapter package, then re-strip
COPY packages/flutter_map_sld_flutter_map/ /app/packages/flutter_map_sld_flutter_map/
RUN sed -i '/^resolution: workspace$/d' pubspec.yaml
# Analyze
FROM flutter-map-base AS flutter-map-analyze
RUN flutter analyze
# Test
FROM flutter-map-base AS flutter-map-test
RUN flutter test
# Doc — generate API documentation.
#
# Generate + extract:
# docker build --target flutter-map-doc -t flutter_map_sld_flutter_map:doc .
# docker run --rm flutter_map_sld_flutter_map:doc | tar -xzf -
FROM flutter-map-base AS flutter-map-doc
RUN dart doc
RUN test -f doc/api/index.html && echo "API docs generated: $(find doc/api -name '*.html' | wc -l) HTML files"
RUN tar -czf /doc-api.tar.gz doc/api
ENTRYPOINT ["cat", "/doc-api.tar.gz"]
# Coverage report.
# flutter test --coverage produces coverage/lcov.info directly.
FROM flutter-map-base AS flutter-map-coverage
RUN flutter test --coverage
RUN lcov --summary coverage/lcov.info
# Coverage threshold check.
FROM flutter-map-coverage AS flutter-map-coverage-check
ARG COVERAGE_MIN=95
RUN awk -F'[,:]' -v min="$COVERAGE_MIN" '\
/^DA:/ { total += 1; if ($3 > 0) hit += 1 } \
END { \
if (total == 0) { \
print "No coverage data found in coverage/lcov.info"; \
exit 1; \
} \
pct = (hit / total) * 100; \
printf "Line coverage: %.2f%% (threshold %.2f%%)\n", pct, min; \
if (pct < min) { exit 2 } \
}' coverage/lcov.info
# Publish dry-run
FROM flutter-map-base AS flutter-map-publish-check
RUN flutter pub publish --dry-run