forked from headlamp-k8s/headlamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
63 lines (43 loc) · 2.11 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
62
63
ARG IMAGE_BASE=alpine:3.15.4
FROM $IMAGE_BASE as base-build
ENV GOPATH=/go \
GOPROXY=https://proxy.golang.org \
GO111MODULE=on
RUN apk update && \
apk add git nodejs npm go ca-certificates make musl-dev bash icu-data
FROM base-build AS backend
COPY ./backend /headlamp/backend
WORKDIR /headlamp
RUN cd ./backend && go build -o ./headlamp-server ./cmd/
# Keep npm install separated so source changes don't trigger install
FROM base-build AS frontendinstall
# We need .git and app/ in order to get the version and git version for the frontend/.env file
# that's generated when building the frontend.
COPY ./.git /headlamp/.git
COPY app/package.json /headlamp/app/package.json
COPY frontend/package*.json /headlamp/frontend/
COPY frontend/patches/* /headlamp/frontend/patches/
WORKDIR /headlamp
RUN cd ./frontend && npm install --only=prod
FROM frontendinstall AS frontend
COPY ./frontend /headlamp/frontend
WORKDIR /headlamp
RUN cd ./frontend && npm run build
RUN echo "*** Built Headlamp with version: ***"
RUN cat ./frontend/.env
# Backwards compatibility, move plugin folder to only copy matching plugins.
RUN mv plugins plugins-old || true
RUN mkdir -p ./plugins
# Backwards compatibility, copy any matching plugins found inside "./plugins-old" into "./plugins".
# They should match plugins-old/MyFolder/main.js, otherwise they are not copied.
RUN for i in $(find ./plugins-old/*/main.js); do plugin_name=$(echo $i|cut -d'/' -f3); mkdir -p plugins/$plugin_name; cp $i plugins/$plugin_name; done
RUN for i in $(find ./.plugins/*/main.js); do plugin_name=$(echo $i|cut -d'/' -f3); mkdir -p plugins/$plugin_name; cp $i plugins/$plugin_name; done
FROM $IMAGE_BASE
COPY --from=backend /headlamp/backend/headlamp-server /headlamp/headlamp-server
COPY --from=frontend /headlamp/frontend/build /headlamp/frontend
COPY --from=frontend /headlamp/plugins /headlamp/plugins
# Create a symlink so we support any attempts to run "/headlamp/server", from before we
# renamed it as "headlamp-server".
RUN cd /headlamp && ln -s ./headlamp-server ./server
EXPOSE 4466
ENTRYPOINT ["/headlamp/headlamp-server", "-html-static-dir", "/headlamp/frontend"]