-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
213 lines (151 loc) · 7.9 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# Apache License 2.0
ARG BASE_IMAGE_VERSION="latest"
# General purpose development image (root user)
FROM openspacecollective/open-space-toolkit-base:${BASE_IMAGE_VERSION} as root-user
LABEL maintainer="[email protected]"
# Dependencies
## Zip, jq, & git-lfs
RUN apt-get update \
&& apt-get install -y unzip jq git-lfs \
&& rm -rf /var/lib/apt/lists/*
## {fmt}
ARG FMT_VERSION="5.2.0"
RUN git clone --branch ${FMT_VERSION} --depth 1 https://github.com/fmtlib/fmt.git /tmp/fmt \
&& cd /tmp/fmt \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE .. \
&& make --silent -j $(nproc) \
&& make install \
&& rm -rf /tmp/fmt
## ordered-map
ARG ORDERED_MAP_VERSION="0.6.0"
RUN git clone --branch v${ORDERED_MAP_VERSION} --depth 1 https://github.com/Tessil/ordered-map.git /tmp/ordered-map \
&& cd /tmp/ordered-map \
&& cp -r ./include/tsl /usr/local/include \
&& rm -rf /tmp/ordered-map
## Eigen
ARG EIGEN_VERSION="3.4.0"
RUN mkdir /tmp/eigen \
&& cd /tmp/eigen \
&& wget --quiet https://gitlab.com/libeigen/eigen/-/archive/${EIGEN_VERSION}/eigen-${EIGEN_VERSION}.tar.gz \
&& tar -xvf eigen-${EIGEN_VERSION}.tar.gz \
&& cd eigen-${EIGEN_VERSION} \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make install \
&& rm -rf /tmp/eigen
## SGP4
ARG SGP4_VERSION="6a448b4"
RUN git clone https://github.com/dnwrnr/sgp4.git /tmp/sgp4 \
&& cd /tmp/sgp4 \
&& git checkout ${SGP4_VERSION} \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_CXX_FLAGS="-fPIC" .. \
&& make -j $(nproc) \
&& mkdir /usr/local/include/sgp4 \
&& cp ../libsgp4/*.h /usr/local/include/sgp4/ \
&& cp libsgp4/*.a /usr/local/lib \
&& rm -rf /tmp/sgp4
## NLopt
ARG NLOPT_VERSION="2.5.0"
RUN git clone --branch v${NLOPT_VERSION} --depth 1 https://github.com/stevengj/nlopt.git /tmp/nlopt \
&& cd /tmp/nlopt \
&& mkdir build \
&& cd build \
&& cmake -DBUILD_SHARED_LIBS=OFF .. \
&& make \
&& make install \
&& rm -rf /tmp/nlopt
## benchmark
ARG BENCHMARK_VERSION="1.8.2"
RUN git clone --branch v${BENCHMARK_VERSION} https://github.com/google/benchmark.git /tmp/benchmark \
&& cd /tmp/benchmark \
&& cmake -E make_directory "build" \
&& cmake -E chdir "build" cmake -DBENCHMARK_DOWNLOAD_DEPENDENCIES=on -DCMAKE_BUILD_TYPE=Release ../ \
&& cmake --build "build" --config Release --target install \
&& rm -rf /tmp/benchmark
## Open Space Toolkit ▸ Core
ARG OSTK_CORE_MAJOR="1"
ARG OSTK_CORE_MINOR="0"
## Force an image rebuild when new Core patch versions are detected
ADD https://api.github.com/repos/open-space-collective/open-space-toolkit-core/git/matching-refs/tags/${OSTK_CORE_MAJOR}.${OSTK_CORE_MINOR} /tmp/open-space-toolkit-core/versions.json
RUN mkdir -p /tmp/open-space-toolkit-core \
&& cd /tmp/open-space-toolkit-core \
&& export LATEST_PATCH_OF_MINOR=$(jq -r .[-1].ref versions.json | cut -d "/" -f3) \
&& wget --quiet https://github.com/open-space-collective/open-space-toolkit-core/releases/download/${LATEST_PATCH_OF_MINOR}/open-space-toolkit-core-${LATEST_PATCH_OF_MINOR}-1.x86_64-runtime.deb \
&& wget --quiet https://github.com/open-space-collective/open-space-toolkit-core/releases/download/${LATEST_PATCH_OF_MINOR}/open-space-toolkit-core-${LATEST_PATCH_OF_MINOR}-1.x86_64-devel.deb \
&& apt-get install -y ./*.deb \
&& rm -rf /tmp/open-space-toolkit-core
## Open Space Toolkit ▸ I/O
ARG OSTK_IO_MAJOR="1"
ARG OSTK_IO_MINOR="0"
## Force an image rebuild when new IO patch versions are detected
ADD https://api.github.com/repos/open-space-collective/open-space-toolkit-io/git/matching-refs/tags/${OSTK_IO_MAJOR}.${OSTK_IO_MINOR} /tmp/open-space-toolkit-io/versions.json
RUN mkdir -p /tmp/open-space-toolkit-io \
&& cd /tmp/open-space-toolkit-io \
&& export LATEST_PATCH_OF_MINOR=$(jq -r .[-1].ref versions.json | cut -d "/" -f3) \
&& wget --quiet https://github.com/open-space-collective/open-space-toolkit-io/releases/download/${LATEST_PATCH_OF_MINOR}/open-space-toolkit-io-${LATEST_PATCH_OF_MINOR}-1.x86_64-runtime.deb \
&& wget --quiet https://github.com/open-space-collective/open-space-toolkit-io/releases/download/${LATEST_PATCH_OF_MINOR}/open-space-toolkit-io-${LATEST_PATCH_OF_MINOR}-1.x86_64-devel.deb \
&& apt-get install -y ./*.deb \
&& rm -rf /tmp/open-space-toolkit-io
## Open Space Toolkit ▸ Mathematics
ARG OSTK_MATHEMATICS_MAJOR="1"
ARG OSTK_MATHEMATICS_MINOR="0"
## Force an image rebuild when new Mathematics patch versions are detected
ADD https://api.github.com/repos/open-space-collective/open-space-toolkit-mathematics/git/matching-refs/tags/${OSTK_MATHEMATICS_MAJOR}.${OSTK_MATHEMATICS_MINOR} /tmp/open-space-toolkit-mathematics/versions.json
RUN mkdir -p /tmp/open-space-toolkit-mathematics \
&& cd /tmp/open-space-toolkit-mathematics \
&& export LATEST_PATCH_OF_MINOR=$(jq -r .[-1].ref versions.json | cut -d "/" -f3) \
&& wget --quiet https://github.com/open-space-collective/open-space-toolkit-mathematics/releases/download/${LATEST_PATCH_OF_MINOR}/open-space-toolkit-mathematics-${LATEST_PATCH_OF_MINOR}-1.x86_64-runtime.deb \
&& wget --quiet https://github.com/open-space-collective/open-space-toolkit-mathematics/releases/download/${LATEST_PATCH_OF_MINOR}/open-space-toolkit-mathematics-${LATEST_PATCH_OF_MINOR}-1.x86_64-devel.deb \
&& apt-get install -y ./*.deb \
&& rm -rf /tmp/open-space-toolkit-mathematics
## Open Space Toolkit ▸ Physics
ARG OSTK_PHYSICS_MAJOR="4"
ARG OSTK_PHYSICS_MINOR="0"
## Force an image rebuild when new Physics patch versions are detected
ADD https://api.github.com/repos/open-space-collective/open-space-toolkit-physics/git/matching-refs/tags/${OSTK_PHYSICS_MAJOR}.${OSTK_PHYSICS_MINOR} /tmp/open-space-toolkit-physics/versions.json
RUN mkdir -p /tmp/open-space-toolkit-physics \
&& cd /tmp/open-space-toolkit-physics \
&& export LATEST_PATCH_OF_MINOR=$(jq -r .[-1].ref versions.json | cut -d "/" -f3) \
&& wget --quiet https://github.com/open-space-collective/open-space-toolkit-physics/releases/download/${LATEST_PATCH_OF_MINOR}/open-space-toolkit-physics-${LATEST_PATCH_OF_MINOR}-1.x86_64-runtime.deb \
&& wget --quiet https://github.com/open-space-collective/open-space-toolkit-physics/releases/download/${LATEST_PATCH_OF_MINOR}/open-space-toolkit-physics-${LATEST_PATCH_OF_MINOR}-1.x86_64-devel.deb \
&& apt-get install -y ./*.deb \
&& rm -rf /tmp/open-space-toolkit-physics
# Install seed data
RUN git clone --branch main --single-branch --depth=1 https://github.com/open-space-collective/open-space-toolkit-data.git /var/cache/open-space-toolkit-data
ENV OSTK_PHYSICS_DATA_LOCAL_REPOSITORY="/var/cache/open-space-toolkit-data/data"
# Labels
ARG VERSION
ENV VERSION="${VERSION}"
LABEL VERSION="${VERSION}"
# Development image for humans (non-root user)
FROM root-user as non-root-user
# Install dev utilities
RUN apt-get update \
&& apt-get install -y zsh sudo \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user and group
ARG USERNAME="developer"
ARG USER_UID="1000"
ARG USER_GID=${USER_UID}
RUN groupadd --gid ${USER_GID} ${USERNAME} || true \
&& adduser --uid ${USER_UID} --gid ${USER_GID} ${USERNAME} \
&& echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/${USERNAME}
# Change ownership of OSTK_PHYSICS_DATA_LOCAL_REPOSITORY
RUN chown -R ${USERNAME}:${USERNAME} ${OSTK_PHYSICS_DATA_LOCAL_REPOSITORY}
# Use non-root user
USER ${USERNAME}
# Install shell utilities
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" \
&& git clone https://github.com/bhilburn/powerlevel9k.git /home/${USERNAME}/.oh-my-zsh/custom/themes/powerlevel9k \
&& git clone https://github.com/zsh-users/zsh-autosuggestions /home/${USERNAME}/.oh-my-zsh/custom/plugins/zsh-autosuggestions \
&& git clone https://github.com/zsh-users/zsh-syntax-highlighting.git /home/${USERNAME}/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting \
&& mkdir -p /home/${USERNAME}/.vscode-server/extensions /home/${USERNAME}/.vscode-server-insiders/extensions
## Configure environment
ENV PATH="/home/${USERNAME}/.local/bin:${PATH}"
# Entrypoint
CMD [ "/bin/bash" ]