-
Notifications
You must be signed in to change notification settings - Fork 5
/
Earthfile
113 lines (95 loc) · 3.82 KB
/
Earthfile
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
VERSION --try --global-cache --arg-scope-and-set 0.7
# If running this target with a local ssh agent active, set the environment
# variable EARTHLY_SSH_AUTH_SOCK='' to make the `+deps` target work. Earthly
# defaults to ssh authentication when it founds an ssh agent active but the
# flutter repo needs to be cloned via https to properly use the `channel`
# subcommand.
deps:
FROM debian:bookworm-slim
ARG TARGETARCH
RUN apt-get update
RUN apt-get install -y git curl unzip bzip2 bash jq gpg lcov
COPY --dir test_driver/scripts .
RUN chmod +x scripts/install-chrome-linux64.sh && ./scripts/install-chrome-linux64.sh
RUN chmod +x scripts/install-edge-linux64.sh && ./scripts/install-edge-linux64.sh
RUN chmod +x scripts/install-firefox-linux64.sh && ./scripts/install-firefox-linux64.sh
WORKDIR /frontend
RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:$HOME/.pub-cache/bin:${PATH}"
RUN flutter channel stable
RUN flutter upgrade
RUN flutter --version
RUN flutter doctor -v
RUN flutter config --enable-web
RUN dart pub global activate melos
RUN dart pub global activate junitreport
RUN dart pub global activate coverage
src:
FROM +deps
COPY --dir pubspec.yaml lib packages web test test_driver integration_test .
# code-generator - Generates flutter code.
# Based on Catalyst Gateway OpenAPI specifications generates models, clients
# and serialization logic.
# It accepts [save_locally] ARG that when true place the artifacts in the
# proper folder of `catalyst_voices_services` local code.
code-generator:
ARG save_locally=false
FROM +deps
COPY --dir pubspec.yaml lib packages web test test_driver integration_test catalyst_voices
COPY ../+repo-catalyst-voices-packages/repo .
WORKDIR /frontend/catalyst_voices/packages/catalyst_voices_services
COPY ../catalyst-gateway+build/doc/cat-gateway-api.json openapi/cat-gateway-api.json
RUN flutter pub get
RUN dart run build_runner build --delete-conflicting-outputs
IF [ $save_locally = true ]
SAVE ARTIFACT lib/generated/catalyst_gateway/* AS LOCAL ./packages/catalyst_voices_services/lib/generated/catalyst_gateway/
ELSE
SAVE ARTIFACT lib/generated/catalyst_gateway
END
# check-flutter-code-generator - Checks that the code generation is consistent
# with the generated code currently in the repo.
check-flutter-code-generator:
FROM +code-generator
# Copy generated files in the local file tree to a temporary folder
COPY packages/catalyst_voices_services/lib/generated/catalyst_gateway /tmp/repo_generated
# Check diff between local code and earthly artifacts
RUN diff /tmp/repo_generated lib/generated/catalyst_gateway
check-static-analysis:
FROM +deps
COPY ../+repo-catalyst-voices-all/repo repo/
WORKDIR repo
RUN melos bootstrap
RUN melos analyze --fatal-infos --fatal-warnings
check-code-formatting:
FROM +deps
COPY ../+repo-catalyst-voices-all/repo repo/
WORKDIR repo
RUN melos bootstrap
RUN melos run format-check
# Build web version of Catalyst Voices
build:
FROM +src
RUN flutter clean
RUN flutter pub get
RUN flutter build web --web-renderer canvaskit --release --target lib/configs/main_web.dart
WORKDIR /frontend/build
SAVE ARTIFACT web /web AS LOCAL web
test-unit:
FROM +deps
COPY ../+repo-catalyst-voices-all/repo repo/
WORKDIR repo
RUN melos run test-report
WAIT
SAVE ARTIFACT test_reports AS LOCAL test_reports
END
package:
FROM nginx:alpine3.18
ARG tag='latest'
COPY +build/web /app
COPY ./nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
SAVE IMAGE voices-frontend:$tag
publish:
FROM +package
ARG tag='latest'
SAVE IMAGE voices-frontend:$tag