-
Notifications
You must be signed in to change notification settings - Fork 2
/
Earthfile
112 lines (94 loc) · 2.87 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
# See Earthfile reference here: https://docs.earthly.dev/docs/earthfile
# This is effectively a Dockerfile + Makefile so you can run reproducible tests
# locally and in continuous integration (e.g. Github Actions)
VERSION 0.6
FROM golang:1.17.9
WORKDIR /runner
ARG dependencies="python3 g++ nodejs"
COPY . .
build-dev:
FROM mcr.microsoft.com/vscode/devcontainers/go:1.17-bullseye
# add more runtime dependencies here
RUN apt-get update -y \
&& apt-get install -y ${dependencies} \
&& go install github.com/spf13/cobra/[email protected] \
&& go install github.com/golang/mock/[email protected]
EXPOSE 10100
ENTRYPOINT ["/bin/bash"]
SAVE IMAGE runner-devcontainer
build-server:
RUN go build -v -o /runner/process /runner/engine/process/ \
&& go build -v -o /runner/runner-server /runner/server/
SAVE ARTIFACT process
SAVE ARTIFACT runner-server
server:
FROM golang:1.17.9
WORKDIR /runner
# add process binary to a directory already in $PATH
COPY +build-server/runner-server ./
COPY +build-server/process /usr/bin
COPY docker/server-debian/entrypoint.sh /runner/entrypoint.sh
RUN apt-get update \
&& apt-get install -y ${dependencies}
EXPOSE 10100
ENV NUM_RUNNERS=${NUM_RUNNERS:-100}
ENTRYPOINT ["/runner/entrypoint.sh", "server"]
SAVE IMAGE runner-server
run-server:
COPY +build-server/process /usr/bin
COPY +build-server/runner-server /usr/bin
build-mock:
FROM golang:1.17.9
WORKDIR /runner
COPY . .
RUN go build -v -o /runner/mock-server /runner/server/mock-server
SAVE ARTIFACT server/mock-server
mock:
FROM golang:1.17.9
WORKDIR /runner
COPY +build-mock/mock-server ./
EXPOSE 10100
ENTRYPOINT ["/runner/mock-server"]
SAVE IMAGE mock-runner-server
vet:
# copy source into container and then run the go vet tool
RUN go vet ./...
lint-sourcecode:
SAVE ARTIFACT .
lint:
FROM golangci/golangci-lint:v1.45.2
WORKDIR /app
COPY +lint-sourcecode/ .
RUN cd /app/runner && golangci-lint run ./... -v
test-go:
# runner-server tests require that the process binary can be built
COPY +build-server/process /usr/bin
RUN UNIT_TEST=1 DEBUG=1 go test -covermode=atomic ./...
RUN cd server && ./test_server_startup.sh
test-web:
# make sure webpack builds
# TODO: this build takes a while it might be hard to do this as a test
RUN cd web-frontend \
&& apt-get update -y \
&& apt-get install -y nodejs npm \
&& npm install \
&& npm run build
test-server-image-build:
FROM DOCKERFILE -f ./docker/server-debian/Dockerfile .
run-ci:
BUILD +test-go
BUILD +lint
BUILD +test-server-image-build
BUILD +test-web
build-frontend:
FROM public.ecr.aws/debian/debian:buster-slim
WORKDIR /frontend
COPY ./web-frontend .
RUN apt-get update -y \
&& apt-get install -y npm \
&& npm install
SAVE ARTIFACT /frontend
frontend:
FROM pierrezemb/gostatic
COPY +build-frontend/frontend/ /srv/http/
SAVE IMAGE runner-frontend