-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.dev
More file actions
179 lines (165 loc) · 6.91 KB
/
Copy pathDockerfile.dev
File metadata and controls
179 lines (165 loc) · 6.91 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
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
# Interactive dev container for satdeploy.
#
# Use case: full Linux dev environment with tmux + editors + build tools where
# the satdeploy source tree is mounted live from the Mac host. Edits on the
# host show up inside the container immediately, builds happen inside the
# container against real Linux libcsp/libdtp/etc. (none of which compile on
# darwin per CLAUDE.md).
#
# Usage:
# ./scripts/docker-dev.sh # build + drop into shell
# docker exec -it satdeploy-dev tmux # second pane via exec
#
# Once inside:
# build-all # alias for both meson+ninja runs
# ./satdeploy-agent/build-native/satdeploy-agent --version
#
# Differs from the verification Dockerfile:
# - source is volume-mounted, not COPY'd in (live edits)
# - no smoke-tests baked into `docker build` (you run them yourself)
# - tmux + vim + nano + gdb + htop + jq + less + man pages
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC
ENV LANG=C.UTF-8
# Build deps + dev quality-of-life. zmqproxy is built from the libcsp source
# tree (lib/csp/utils/zmqproxy.c), not an apt package — don't add one.
# CSH-specific deps included: libcurl4-openssl-dev, libelf-dev, libbsd-dev,
# can-utils, fonts-powerline (per spaceinventor/csh README).
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ninja-build \
pkg-config \
libssl-dev \
libsocketcan-dev \
libzmq3-dev \
libprotobuf-c-dev \
protobuf-c-compiler \
libyaml-dev \
libsqlite3-dev \
libcurl4-openssl-dev \
libelf-dev \
libbsd-dev \
can-utils \
iproute2 \
fonts-powerline \
tmux \
vim \
nano \
less \
man-db \
manpages \
manpages-dev \
htop \
gdb \
valgrind \
strace \
ltrace \
file \
tree \
jq \
ripgrep \
fd-find \
curl \
wget \
git \
openssh-client \
ca-certificates \
sudo \
bash-completion \
python3 \
python3-dev \
python3-pip \
pipx \
&& rm -rf /var/lib/apt/lists/*
# CSH's meson.build requires meson_version >= 1.6, but Ubuntu 24.04 ships 1.3.
# Install a recent meson via pip globally (--break-system-packages bypasses
# PEP 668; safe in a container). satdeploy-agent + apm build fine with the
# newer meson.
RUN pip3 install --break-system-packages meson \
&& meson --version
# Build CSH from source. Pinned to HEAD by default; override with
# --build-arg CSH_REF=<commit-or-tag>. The CSP submodule version that CSH
# pulls in must match the APM's libcsp version (per CLAUDE.md): linking the
# static CSP lib in the APM would normally embed uninitialized globals that
# shadow CSH's, but the APM's meson.build uses partial_dependency to take
# headers only, sidestepping the issue. Even so, struct layout has to match
# at runtime — if you bump the APM's lib/csp submodule, rebuild CSH against
# the matching ref by passing --build-arg CSH_REF=<that-ref>.
ARG CSH_REF=HEAD
RUN git clone --recurse-submodules https://github.com/spaceinventor/csh.git /opt/csh \
&& cd /opt/csh \
&& if [ "$CSH_REF" != "HEAD" ]; then \
git fetch --depth 50 origin "$CSH_REF" \
&& git checkout "$CSH_REF" \
&& git submodule update --init --recursive ; \
fi \
&& meson setup builddir \
&& ninja -C builddir \
&& ln -s /opt/csh/builddir/csh /usr/local/bin/csh \
&& ln -s /opt/csh/builddir/zmqproxy /usr/local/bin/zmqproxy \
&& mkdir -p /root/.local/lib/csh \
&& test -x /usr/local/bin/csh && test -x /usr/local/bin/zmqproxy
# The dev shell helpers live in scripts/dev-shell.sh in the repo so they can
# be tweaked without a docker rebuild — the volume mount makes host edits
# immediately available inside the container. The /etc/profile.d entry just
# sources that file (with a fallback if the volume isn't mounted).
RUN cat >/etc/profile.d/satdeploy.sh <<'PRF'
if [ -r /satdeploy/scripts/dev-shell.sh ]; then
. /satdeploy/scripts/dev-shell.sh
fi
PRF
# Make interactive shells also pick up the profile.d script (Ubuntu's
# /etc/bash.bashrc is sourced for interactive non-login shells; without
# this hook those would miss the helpers).
RUN echo 'for f in /etc/profile.d/*.sh; do [ -r "$f" ] && . "$f"; done' \
>>/etc/bash.bashrc
# Welcome banner runs once per top-level entry. $TMUX is set inside tmux
# panes — skipping the MOTD there avoids printing it in every new pane.
RUN cat >/etc/profile.d/satdeploy-motd.sh <<'MOTD'
[ -n "$TMUX" ] && return 0
cat <<EOF
─────────────────────────────────────────────────────
satdeploy dev container
/satdeploy — your repo (live-mounted from the Mac)
build-agent — meson + ninja for the agent
build-apm — meson + ninja for the APM (auto-installs the .so)
build-all — both
agent --version — shorthand for the built agent binary
csh — CSP shell (dlopens APMs from ~/.local/lib/csh/)
csh-zmq — csh -i /satdeploy/init/zmq.csh (CSP-on-ZMQ ground)
zmqproxy — CSP ZMQ broker (built alongside CSH)
tmux — multi-pane terminal
Workflow for end-to-end CSP test:
tmux # split window
pane 1: zmqproxy # CSP localhost transport
pane 2: agent -i ZMQ -p localhost -a 5425
pane 3: build-apm && csh-zmq
csh> apm load
csh> satdeploy status -n 5425
csh> satdeploy push controller
Native build is x86_64 (or arm64 on Apple Silicon Docker) — fine for
verification, NEVER for flight. Real flight builds go through Yocto.
─────────────────────────────────────────────────────
EOF
MOTD
# Tmux config: scrollback, mouse, and pane-split bindings the user asked for.
# prefix v → vertical-line split (panes side-by-side, split-window -h)
# prefix s → horizontal-line split (panes stacked, split-window -v)
# `unbind s` first because it normally maps to choose-tree (session list).
RUN cat >/root/.tmux.conf <<'TCONF'
set -g history-limit 50000
set -g mouse on
set -g default-terminal "screen-256color"
set -g status-bg colour235
set -g status-fg colour250
unbind s
bind v split-window -hc "#{pane_current_path}"
bind s split-window -vc "#{pane_current_path}"
TCONF
WORKDIR /satdeploy
# Auto-launch the entry script on container entry. It pre-builds, starts
# zmqproxy in background, and opens a 2-pane tmux session (csh on left,
# agent on right). The script lives in /satdeploy so edits don't require
# a docker rebuild.
CMD ["/satdeploy/scripts/docker-entry.sh"]