Repository navigation
Expand file tree
/
Copy pathsplinter-dev
More file actions
124 lines (109 loc) · 4.07 KB
/
Copy pathsplinter-dev
File metadata and controls
124 lines (109 loc) · 4.07 KB
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
119
120
121
122
123
124
# Copyright 2018-2020 Cargill Incorporated
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM ubuntu:bionic
# Install base dependencies
RUN apt-get update \
&& apt-get install -y -q \
build-essential \
curl \
g++ \
gcc \
git \
libpq-dev \
libsasl2-dev \
libssl-dev \
libzmq3-dev \
openssl \
pandoc \
pkg-config \
python \
unzip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV PATH=$PATH:/root/.cargo/bin
# Install Rust
RUN curl https://sh.rustup.rs -sSf > /usr/bin/rustup-init \
&& chmod +x /usr/bin/rustup-init \
&& rustup-init -y
# Install cargo deb
RUN cargo install cargo-deb
# Install protoc
RUN curl -OLsS https://github.com/google/protobuf/releases/download/v3.7.1/protoc-3.7.1-linux-x86_64.zip \
&& unzip -o protoc-3.7.1-linux-x86_64.zip -d /usr/local \
&& rm protoc-3.7.1-linux-x86_64.zip
# Create empty cargo projects for top-level projects
WORKDIR /build
RUN USER=root cargo new --bin cli
RUN USER=root cargo new --bin client
RUN USER=root cargo new --lib libsplinter
RUN USER=root cargo new --bin splinterd
# Create empty Cargo projects for gameroom
RUN USER=root cargo new --bin examples/gameroom/cli
RUN USER=root cargo new --bin examples/gameroom/daemon
RUN USER=root cargo new --bin examples/gameroom/database
# Create empty Cargo projects for splinter services
RUN USER=root cargo new --bin services/health
RUN USER=root cargo new --bin services/scabbard/cli
RUN USER=root cargo new --lib services/scabbard/libscabbard
# Copy over splinter files
COPY Cargo.toml /build/Cargo.toml
COPY cli/Cargo.toml /build/cli/Cargo.toml
COPY client/Cargo.toml /build/client/Cargo.toml
COPY libsplinter/build.rs /build/libsplinter/build.rs
COPY libsplinter/Cargo.toml /build/libsplinter/Cargo.toml
COPY libsplinter/protos /build/libsplinter/protos
COPY splinterd/Cargo.toml /build/splinterd/Cargo.toml
COPY services/health/Cargo.toml /build/services/health/Cargo.toml
COPY services/scabbard/cli/Cargo.toml /build/services/scabbard/cli/Cargo.toml
COPY services/scabbard/libscabbard/build.rs /build/services/scabbard/libscabbard/build.rs
COPY services/scabbard/libscabbard/Cargo.toml /build/services/scabbard/libscabbard/Cargo.toml
COPY services/scabbard/libscabbard/protos /build/services/scabbard/libscabbard/protos
# Copy over example Cargo.toml files
COPY examples/gameroom/cli/Cargo.toml \
/build/examples/gameroom/cli/Cargo.toml
COPY examples/gameroom/daemon/Cargo.toml \
/build/examples/gameroom/daemon/Cargo.toml
COPY examples/gameroom/database/Cargo.toml \
/build/examples/gameroom/database/Cargo.toml
# Do release builds for each Cargo.toml
RUN find . -name 'Cargo.toml' -exec \
sh -c 'x="{}"; cargo build --release --manifest-path "$x" ' \;
# Clean up built files
RUN rm \
target/release/gameroom-database* \
target/release/gameroomd* \
target/release/health* \
target/release/libsplinter* \
target/release/scabbard* \
target/release/splinter-cli* \
target/release/splinterd* \
target/release/deps/gameroom_database* \
target/release/deps/gameroomd* \
target/release/deps/health* \
target/release/deps/libsplinter* \
target/release/deps/scabbard* \
target/release/deps/splinter_cli* \
target/release/deps/splinterd*
# Clean up leftover files
RUN find . -name 'Cargo.toml' -exec \
sh -c 'x="{}"; rm "$x" ' \;
RUN rm /build/libsplinter/build.rs \
/build/libsplinter/protos/* \
/build/services/scabbard/libscabbard/build.rs \
/build/services/scabbard/libscabbard/protos/*
# Log the commit hash
COPY .git/ /tmp/.git/
WORKDIR /tmp
RUN git rev-parse HEAD > /commit-hash
WORKDIR /build