-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (42 loc) · 1.19 KB
/
Dockerfile
File metadata and controls
55 lines (42 loc) · 1.19 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
ARG GO_VERSION=1.24
ARG ALPINE_VERSION=3.22
FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS build
WORKDIR /app
RUN apk -U add nodejs npm
COPY go.mod go.sum ./
RUN \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/root/go \
go mod download
COPY package.json package-lock.json ./
RUN \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/root/go \
--mount=type=cache,target=/app/node_modules \
npm ci
COPY . .
ARG TARGETOS
ARG TARGETARCH
RUN \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/root/go \
--mount=type=cache,target=/app/node_modules \
npm run generate
RUN \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/root/go \
--mount=type=cache,target=/app/node_modules \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
CGO_ENABLED=0 \
go build \
-gcflags "all=-N -l" \
-o /app/bin/web \
./cmd/web
FROM alpine:${ALPINE_VERSION} AS run
WORKDIR /app
RUN apk -U add ca-certificates mailcap \
&& mkdir -p /app/var
COPY --from=build /app/bin/web /app/bin/web
CMD ["/app/bin/web"]
LABEL org.opencontainers.image.source="https://github.com/tigrisdata-community/tygen"