-
Notifications
You must be signed in to change notification settings - Fork 11
/
Dockerfile
86 lines (65 loc) · 2.33 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
###################################################
# Cloud-Barista CB-Dragonfly Module Dockerfile #
###################################################
# Go 빌드 이미지 버전 및 알파인 OS 버전 정보
ARG BASE_IMAGE_BUILDER=golang
ARG GO_VERSION=1.21.4
ARG ALPINE_VERSION=3
###################################################
# 1. Build CB-Dragonfly binary file
###################################################
FROM ${BASE_IMAGE_BUILDER}:${GO_VERSION}-alpine AS go-builder
ENV CGO_ENABLED=1
ENV GO111MODULE="on"
ENV GOOS="linux"
ENV GOARCH="amd64"
ENV GOPATH="/go"
#ARG GO_FLAGS="-mod=vendor"
ARG LD_FLAGS="-s -w"
ARG OUTPUT="bin/cb-dragonfly"
WORKDIR ${GOPATH}/src/github.com/cloud-barista/cb-dragonfly
COPY . ./
RUN apk add --update gcc
RUN apk add --no-cache \
bash \
build-base \
gcc \
make \
musl-dev \
tzdata \
librdkafka-dev \
pkgconf
RUN go mod vendor && go build -tags musl ${GO_FLAGS} -ldflags "${LD_FLAGS}" -o ${OUTPUT} ./pkg \
&& chmod +x ${OUTPUT}
###################################################
# 2. Set up CB-Dragonfly runtime environment
###################################################
FROM alpine:${ALPINE_VERSION} AS runtime-alpine
ENV TZ="Asia/Seoul"
RUN apk add --no-cache \
bash \
tzdata \
librdkafka-dev \
pkgconf \
&& \
cp --remove-destination /usr/share/zoneinfo/${TZ} /etc/localtime \
&& \
echo "${TZ}" > /etc/timezone
###################################################
# 3. Execute CB-Dragonfly Module
###################################################
FROM runtime-alpine as cb-dragonfly
LABEL maintainer="innogrid <[email protected]>"
RUN apk add --no-cache sudo
ENV GOPATH="/go"
ENV CBSTORE_ROOT=${GOPATH}/src/github.com/cloud-barista/cb-dragonfly
ENV CBLOG_ROOT=${GOPATH}/src/github.com/cloud-barista/cb-dragonfly
ENV CBMON_ROOT=${GOPATH}/src/github.com/cloud-barista/cb-dragonfly
COPY --from=go-builder ${GOPATH}/src/github.com/cloud-barista/cb-dragonfly/file ${GOPATH}/src/github.com/cloud-barista/cb-dragonfly/file
WORKDIR /opt/cb-dragonfly
COPY --from=go-builder ${GOPATH}/src/github.com/cloud-barista/cb-dragonfly/bin/cb-dragonfly /opt/cb-dragonfly/bin/cb-dragonfly
RUN chmod +x /opt/cb-dragonfly/bin/cb-dragonfly \
&& ln -s /opt/cb-dragonfly/bin/cb-dragonfly /usr/bin
EXPOSE 9090
EXPOSE 9999
ENTRYPOINT ["cb-dragonfly"]