-
Notifications
You must be signed in to change notification settings - Fork 13
/
Dockerfile
195 lines (162 loc) · 6.25 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Use this with
#
# docker build -t mission_control .
#
# The docker image. To update, run `docker pull ubuntu` locally, and update the
# sha256:... accordingly.
FROM --platform=linux/amd64 ubuntu@sha256:bbf3d1baa208b7649d1d0264ef7d522e1dc0deeeaaf6085bf8e4618867f03494 as deps
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
apt -yq update && \
apt -yqq install --no-install-recommends curl ca-certificates \
build-essential pkg-config libssl-dev llvm-dev liblmdb-dev clang cmake jq
ENV NODE_VERSION=22.11.0
# Install node
RUN curl --fail -sSf https://raw.githubusercontent.com/creationix/nvm/v0.39.7/install.sh | bash
ENV NVM_DIR=/root/.nvm
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
RUN node --version
RUN npm --version
# Install Rust and Cargo in /opt
ENV RUSTUP_HOME=/opt/rustup \
CARGO_HOME=/cargo \
PATH=/cargo/bin:$PATH
COPY ./docker ./docker
COPY ./rust-toolchain.toml ./rust-toolchain.toml
RUN ./docker/bootstrap
# Pre-build all cargo dependencies. Because cargo doesn't have a build option
# to build only the dependecies, we pretend that our project is a simple, empty
# `lib.rs`. When we COPY the actual files we make sure to `touch` lib.rs so
# that cargo knows to rebuild it with the new content.
COPY Cargo.lock .
COPY Cargo.toml .
COPY src/console/Cargo.toml src/console/Cargo.toml
COPY src/observatory/Cargo.toml src/observatory/Cargo.toml
COPY src/orbiter/Cargo.toml src/orbiter/Cargo.toml
COPY src/mission_control/Cargo.toml src/mission_control/Cargo.toml
COPY src/satellite/Cargo.toml src/satellite/Cargo.toml
COPY src/libs/macros/Cargo.toml src/libs/macros/Cargo.toml
COPY src/libs/satellite/Cargo.toml src/libs/satellite/Cargo.toml
COPY src/libs/shared/Cargo.toml src/libs/shared/Cargo.toml
COPY src/libs/utils/Cargo.toml src/libs/utils/Cargo.toml
COPY src/libs/collections/Cargo.toml src/libs/collections/Cargo.toml
COPY src/libs/storage/Cargo.toml src/libs/storage/Cargo.toml
ENV CARGO_TARGET_DIR=/cargo_target
RUN mkdir -p src/console/src \
&& touch src/console/src/lib.rs \
&& mkdir -p src/observatory/src \
&& touch src/observatory/src/lib.rs \
&& mkdir -p src/orbiter/src \
&& touch src/orbiter/src/lib.rs \
&& mkdir -p src/mission_control/src \
&& touch src/mission_control/src/lib.rs \
&& mkdir -p src/satellite/src \
&& touch src/satellite/src/lib.rs \
&& mkdir -p src/libs/macros/src \
&& touch src/libs/macros/src/lib.rs \
&& mkdir -p src/libs/satellite/src \
&& touch src/libs/satellite/src/lib.rs \
&& mkdir -p src/libs/shared/src \
&& touch src/libs/shared/src/lib.rs \
&& mkdir -p src/libs/utils/src \
&& touch src/libs/utils/src/lib.rs \
&& mkdir -p src/libs/collections/src \
&& touch src/libs/collections/src/lib.rs \
&& mkdir -p src/libs/storage/src \
&& touch src/libs/storage/src/lib.rs \
&& ./docker/build --only-dependencies \
&& rm -rf src
FROM deps as build_mission_control
COPY . .
RUN touch src/console/src/lib.rs
RUN touch src/observatory/src/lib.rs
RUN touch src/orbiter/src/lib.rs
RUN touch src/mission_control/src/lib.rs
RUN touch src/satellite/src/lib.rs
RUN touch src/libs/macros/src/lib.rs
RUN touch src/libs/satellite/src/lib.rs
RUN touch src/libs/shared/src/lib.rs
RUN touch src/libs/utils/src/lib.rs
RUN touch src/libs/collections/src/lib.rs
RUN touch src/libs/storage/src/lib.rs
RUN npm ci
RUN ./docker/build
RUN sha256sum /mission_control.wasm.gz
FROM deps as build_satellite
COPY . .
RUN touch src/console/src/lib.rs
RUN touch src/observatory/src/lib.rs
RUN touch src/orbiter/src/lib.rs
RUN touch src/mission_control/src/lib.rs
RUN touch src/satellite/src/lib.rs
RUN touch src/libs/macros/src/lib.rs
RUN touch src/libs/satellite/src/lib.rs
RUN touch src/libs/shared/src/lib.rs
RUN touch src/libs/utils/src/lib.rs
RUN touch src/libs/collections/src/lib.rs
RUN touch src/libs/storage/src/lib.rs
RUN ./docker/build --satellite
RUN sha256sum /satellite.wasm.gz
FROM deps as build_console
COPY . .
RUN touch src/console/src/lib.rs
RUN touch src/observatory/src/lib.rs
RUN touch src/orbiter/src/lib.rs
RUN touch src/mission_control/src/lib.rs
RUN touch src/satellite/src/lib.rs
RUN touch src/libs/macros/src/lib.rs
RUN touch src/libs/satellite/src/lib.rs
RUN touch src/libs/shared/src/lib.rs
RUN touch src/libs/utils/src/lib.rs
RUN touch src/libs/collections/src/lib.rs
RUN touch src/libs/storage/src/lib.rs
RUN ./docker/build --console
RUN sha256sum /console.wasm.gz
FROM deps as build_observatory
COPY . .
RUN touch src/console/src/lib.rs
RUN touch src/observatory/src/lib.rs
RUN touch src/orbiter/src/lib.rs
RUN touch src/mission_control/src/lib.rs
RUN touch src/satellite/src/lib.rs
RUN touch src/libs/macros/src/lib.rs
RUN touch src/libs/satellite/src/lib.rs
RUN touch src/libs/shared/src/lib.rs
RUN touch src/libs/utils/src/lib.rs
RUN touch src/libs/collections/src/lib.rs
RUN touch src/libs/storage/src/lib.rs
RUN ./docker/build --observatory
RUN sha256sum /observatory.wasm.gz
FROM deps as build_orbiter
COPY . .
RUN touch src/console/src/lib.rs
RUN touch src/observatory/src/lib.rs
RUN touch src/orbiter/src/lib.rs
RUN touch src/mission_control/src/lib.rs
RUN touch src/satellite/src/lib.rs
RUN touch src/libs/macros/src/lib.rs
RUN touch src/libs/satellite/src/lib.rs
RUN touch src/libs/shared/src/lib.rs
RUN touch src/libs/utils/src/lib.rs
RUN touch src/libs/collections/src/lib.rs
RUN touch src/libs/storage/src/lib.rs
RUN ./docker/build --orbiter
RUN sha256sum /orbiter.wasm.gz
FROM scratch AS scratch_mission_control
COPY --from=build_mission_control /mission_control.wasm.gz /
COPY --from=build_mission_control /mission_control.did /
FROM scratch AS scratch_satellite
COPY --from=build_satellite /satellite.wasm.gz /
COPY --from=build_satellite /satellite.did /
FROM scratch AS scratch_console
COPY --from=build_console /console.wasm.gz /
COPY --from=build_console /console.did /
FROM scratch AS scratch_observatory
COPY --from=build_observatory /observatory.wasm.gz /
COPY --from=build_observatory /observatory.did /
FROM scratch AS scratch_orbiter
COPY --from=build_orbiter /orbiter.wasm.gz /
COPY --from=build_orbiter /orbiter.did /