-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile
53 lines (38 loc) · 1.26 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
FROM golang:1.21-alpine as api-builder
ARG API_BIN_NAME=xp-management
ENV GO111MODULE=on \
GOOS=linux \
GOARCH=amd64
WORKDIR /app
COPY . .
# Build Management Service binary
WORKDIR /app/management-service
RUN go build \
-mod=vendor \
-o ./bin/${API_BIN_NAME}
FROM alpine:latest
# Install bash
USER root
RUN apk add --no-cache bash
ARG API_BIN_NAME=xp-management
ARG XP_UI_DIST_PATH=ui/build
ENV XPUICONFIG_SERVINGDIRECTORY "/app/xp-ui"
ENV XP_PORT "8080"
ENV XP_USER "xp"
ENV XP_USER_GROUP "app"
EXPOSE ${XP_PORT}
RUN addgroup -S ${XP_USER_GROUP} \
&& adduser -S ${XP_USER} -G ${XP_USER_GROUP} -H \
&& mkdir /app \
&& chown -R ${XP_USER}:${XP_USER_GROUP} /app
COPY --chown=${XP_USER}:${XP_USER_GROUP} management-service/bin/*.yaml /app/
COPY --from=api-builder --chown=${XP_USER}:${XP_USER_GROUP} /app/management-service/bin/* /app/
COPY --from=api-builder --chown=${XP_USER}:${XP_USER_GROUP} /app/management-service/database /app/database/
USER ${XP_USER}
WORKDIR /app
# UI must be built outside docker
COPY --chown=${XP_USER}:${XP_USER_GROUP} ${XP_UI_DIST_PATH} ${XPUICONFIG_SERVINGDIRECTORY}/
COPY ./docker-entrypoint.sh ./
ENV XP_API_BIN "./${API_BIN_NAME}"
ENV XP_UI_DIST_DIR ${XPUICONFIG_SERVINGDIRECTORY}
ENTRYPOINT [ "./docker-entrypoint.sh" ]