-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
60 lines (42 loc) · 1.54 KB
/
Dockerfile
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
FROM node:18-alpine AS frontend
WORKDIR /build
COPY ./package.json ./package.json
COPY ./package-lock.json ./package-lock.json
RUN --mount=type=cache,target=node_modules npm ci
COPY ./src ./src
RUN --mount=type=cache,target=node_modules npm run test
COPY ./README.md ./README.md
COPY ./CHANGELOG.md ./CHANGELOG.md
COPY ./LICENSE ./LICENSE
RUN --mount=type=cache,target=node_modules npm run build
FROM golang:1.20-alpine AS backend
RUN apk add --no-cache --virtual .build-deps \
binutils-gold \
git \
build-base \
&& go install github.com/magefile/[email protected] \
&& go install github.com/golangci/golangci-lint/cmd/[email protected]
WORKDIR /build
COPY ./go.mod ./go.mod
COPY ./go.sum ./go.sum
RUN go mod download
COPY ./pkg ./pkg
RUN --mount=type=cache,target=/root/.cache/golangci golangci-lint run ./pkg/...
RUN --mount=type=cache,target=/root/.cache/go-build go test -v ./pkg/...
COPY ./src/plugin.json ./src/plugin.json
COPY ./Magefile.go ./Magefile.go
RUN --mount=type=cache,target=/root/.cache/go-build mage \
build:darwin \
build:darwinARM64 \
build:linux \
build:linuxARM \
build:linuxARM64 \
build:windows
FROM scratch
COPY --from=frontend /build/dist /
COPY --from=backend /build/dist/gpx_enapter_api_darwin_amd64 /
COPY --from=backend /build/dist/gpx_enapter_api_darwin_arm64 /
COPY --from=backend /build/dist/gpx_enapter_api_linux_amd64 /
COPY --from=backend /build/dist/gpx_enapter_api_linux_arm /
COPY --from=backend /build/dist/gpx_enapter_api_linux_arm64 /
COPY --from=backend /build/dist/gpx_enapter_api_windows_amd64.exe /