-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
118 lines (95 loc) · 3.3 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# syntax=docker/dockerfile:1
# We use a multi-stage build setup.
# (https://docs.docker.com/build/building/multi-stage/)
###############################################################################
# Stage 1 (to create a "build" image, ~850MB) #
###############################################################################
# Image from https://hub.docker.com/_/golang
FROM golang:1.22.2 AS builder
# smoke test to verify if golang is available
RUN go version
ARG PROJECT_VERSION
COPY ./dstest /go/src/dstest/
WORKDIR /go/src/dstest/
RUN set -Eeux && \
go mod download && \
go mod verify
RUN GOOS=linux GOARCH=amd64 \
go build \
-trimpath \
-ldflags="-w -s -X 'main.Version=${PROJECT_VERSION}'" \
-o cmd/dstest/main cmd/dstest/main.go
RUN go test -cover -v ./...
###############################################################################
# Stage 2 (braft) #
###############################################################################
FROM ubuntu:24.04 AS braft-builder
WORKDIR /src/braft_builder
#build brpc-install dependencies
#for out of sync host machines -> RUN apt-get -o Acquire::Check-Valid-Until=false update
RUN apt-get update && apt-get install -y \
git \
g++ \
make \
libssl-dev \
libgflags-dev \
libprotobuf-dev \
libprotoc-dev \
protobuf-compiler \
libleveldb-dev \
libsnappy-dev \
libgoogle-perftools-dev \
cmake \
libgtest-dev \
dos2unix
#build brpc
COPY ./brpc /src/braft_builder/brpc
WORKDIR /src/braft_builder/brpc/build
RUN cmake .. && make -j6 && make install
#WORKDIR /src/braft_builder/brpc/example/echo_c++
#RUN cmake -B build && cmake --build build -j4
#build braft
WORKDIR /src/braft_builder
COPY ./braft /src/braft_builder/braft
WORKDIR /src/braft_builder/braft/bld
RUN cmake -DBRPC_DIR=/src/braft_builder/brpc .. && make -j6
#build the counter example of braft
#from braft-example - this is a special example choose another name to not confuse with braft examples
COPY ./braft-example/counter_modified /src/braft_builder/braft/example/counter_modified
WORKDIR /src/braft_builder/braft/example/counter_modified
RUN cmake -DBRPC_DIR=/src/braft_builder . && make -j6
#need to do the following for some reason.
RUN dos2unix /src/braft_builder/braft/example/shflags
###############################################################################
# Stage 3 (to create a downsized "container executable", ~5MB) #
###############################################################################
FROM ubuntu:24.04
RUN apt-get update
RUN apt-get install -y openjdk-17-jre-headless golang-go
RUN apt-get update && apt-get install -y \
git \
g++ \
make \
libssl-dev \
libgflags-dev \
libprotobuf-dev \
libprotoc-dev \
protobuf-compiler \
libleveldb-dev \
libsnappy-dev \
libgoogle-perftools-dev \
cmake \
psmisc
WORKDIR /root
COPY --from=builder /go/src/dstest /root/dstest
COPY --from=braft-builder /src/braft_builder/brpc /root/brpc
COPY --from=braft-builder /src/braft_builder/braft /root/braft
# root
# brpc
# braft
# example/counter_modified
# dstest
#
WORKDIR /root/dstest/cmd/dstest/
ENTRYPOINT ["./main"]
CMD ["run", "-c", "/configs/braft2.yml"]