This repository has been archived by the owner on Nov 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Dockerfile
76 lines (65 loc) · 2.16 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
# Define a pretty big base build image, with C++ build-time dependencies
FROM debian:buster-slim AS buildimg
ENV DEBIAN_FRONTEND=noninteractive
# fmt is compiled from source, since buster's versions are slightly off
ENV FMT_VERSION 6.1.2
RUN apt-get update && apt-get install --no-install-recommends -y \
build-essential \
cmake \
pkg-config \
wget \
unzip \
libspdlog-dev \
libmsgpack-dev \
ca-certificates
WORKDIR /src
RUN wget -q https://github.com/fmtlib/fmt/releases/download/${FMT_VERSION}/fmt-${FMT_VERSION}.zip
RUN unzip fmt-${FMT_VERSION}.zip
# Since this is a docker build, just build the dependencies statically. It
# makes copying a tad easier, and it makes go happy. This is in no way a
# requirement though, and oneseismic is perfectly happy to dynamically link.
WORKDIR /src/fmt-${FMT_VERSION}/build
RUN cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DFMT_TEST=OFF \
-DCMAKE_INSTALL_PREFIX=/usr/local \
/src/fmt-${FMT_VERSION}
RUN make -j4 install
FROM buildimg AS cppbuilder
WORKDIR /src
COPY core/ core
WORKDIR /src/build
RUN cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_CXX_FLAGS=-DFMT_HEADER_ONLY=1 \
-DCMAKE_INSTALL_PREFIX=/usr/local \
/src/core
RUN make -j4 install
FROM golang:1.16-buster as gobuilder
COPY --from=cppbuilder /usr/local /usr/local
ENV CGO_CXXFLAGS="-std=c++17"
WORKDIR /src
COPY api/go.mod .
COPY api/go.sum .
RUN go mod download
COPY api api
WORKDIR /src/api
RUN go test -race ./...
RUN go install ./...
# The final image with only the binaries and runtime dependencies
FROM debian:buster-slim as deployimg
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y \
ca-certificates \
&& apt-get clean -y \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists
COPY --from=gobuilder /go/bin/query /bin/oneseismic-query
COPY --from=gobuilder /go/bin/result /bin/oneseismic-result
COPY --from=gobuilder /go/bin/fetch /bin/oneseismic-fetch
COPY --from=gobuilder /go/bin/gc /bin/oneseismic-gc
COPY --from=gobuilder /go/bin/catalogue /bin/oneseismic-catalogue