-
Notifications
You must be signed in to change notification settings - Fork 27
/
Dockerfile
61 lines (45 loc) · 1.85 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
61
# ============== Frontend ==============
FROM node:10 as frontend-builder
WORKDIR /workspace
# Frontend and api will run on the same domain
ENV REACT_APP_K8S_API_PERFIX ""
ENV REACT_APP_K8S_API_VERSION v1alpha1
ENV SKIP_PREFLIGHT_CHECK=true
# Copy npm packages manifests
COPY frontend/package.json package.json
COPY frontend/package-lock.json package-lock.json
RUN npm install
# Copy source
COPY frontend/ .
# Build
RUN npm run build
# ============== Api ==============
FROM golang:1.15.2 as api-builder
WORKDIR /workspace/api
# Copy dependencies
COPY controller/ /workspace/controller
# Copy the Go Modules manifests
COPY api/go.mod go.mod
COPY api/go.sum go.sum
RUN go mod download
# Copy the go source
COPY api/ .
ARG KALM_BUILD_ENV_GIT_VERSION
ARG KALM_BUILD_ENV_GIT_COMMIT
# Build
RUN CGO_ENABLED=1 go build -installsuffix 'static' \
-ldflags "-X github.com/kalmhq/kalm/api/config.GIT_VERSION=$KALM_BUILD_ENV_GIT_VERSION -X github.com/kalmhq/kalm/api/config.GIT_COMMIT=$KALM_BUILD_ENV_GIT_COMMIT -X 'github.com/kalmhq/kalm/api/config.BUILD_TIME=$(date -Iseconds)' -X 'github.com/kalmhq/kalm/api/config.PLATFORM=$(go version | cut -d ' ' -f 4)' -X 'github.com/kalmhq/kalm/api/config.GO_VERSION=$(go version | cut -d ' ' -f 3)' -extldflags '-static'" \
-o kalm-api-server main.go
RUN go build -ldflags "-s -w" -o auth-proxy ./cmd/auth-proxy
RUN go build -ldflags "-s -w" -o imgconv ./cmd/imgconv
# ============== Finial ==============
FROM alpine
WORKDIR /workspace
# tell kalm api server the location of static files
ENV STATIC_FILE_ROOT build
# Collect binaries and assets
COPY --from=api-builder /workspace/api/kalm-api-server .
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
COPY --from=api-builder /workspace/api/auth-proxy .
COPY --from=api-builder /workspace/api/imgconv .
COPY --from=frontend-builder /workspace/build/ build/