Skip to content

Commit 5acf2d2

Browse files
committed
feat: support for server-side log aggregation
Also: - general fixes for dockerized execution - codeflare dashboard -a updates - dashboard -a does not accept -p
1 parent 45877e4 commit 5acf2d2

File tree

15 files changed

+228
-83
lines changed

15 files changed

+228
-83
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
store/**/*.md

bin/codeflare

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ SCRIPTDIR=$(cd $(dirname "$0") && pwd)
1919
if [ -n "$NODE" ] && [ -n "$HEADLESS" ]; then
2020
# no-op; use built-in node
2121
______USING_BUILTIN=true # not needed, just making bash happy
22+
elif [ -n "$CODEFLARE_HEADLESS_HOME" ]; then
23+
NODE=node
24+
HEADLESS="$CODEFLARE_HEADLESS_HOME"
2225
elif [ -f ${SCRIPTDIR}/../node_modules/electron/dist/Electron.app/Contents/MacOS/Electron ]; then
2326
# development mode on MacOS
2427
NODE=${SCRIPTDIR}/../node_modules/electron/dist/Electron.app/Contents/MacOS/Electron
@@ -100,6 +103,9 @@ if [ -z "$GUIDEBOOK_STORE" ]; then
100103
if [ -d "$HEADLESS"/../../store ]; then
101104
# development builds
102105
export GUIDEBOOK_STORE="$HEADLESS"/../../store
106+
elif [ -d "$HEADLESS"/store ]; then
107+
# docker builds
108+
export GUIDEBOOK_STORE="$HEADLESS"/store
103109
else
104110
# otherwise, we can't find a local mirror, so pull directly from
105111
# git (network transfers!)
@@ -134,7 +140,7 @@ if [ "$do_cli" = "1" ]; then
134140
fi
135141

136142
# Linux may not have the prereqs needed to run Electron
137-
if [ ! -f ~/.codeflare ] && [ $(uname) = Linux ]; then
143+
if [ "$NODE" != "node" ] && [ ! -f ~/.codeflare ] && [ $(uname) = Linux ]; then
138144
if [ "$(grep '^ID_LIKE' /etc/os-release)" = "ID_LIKE=debian" ]; then
139145
if [ $(apt -qq list sudo curl libx11-6 libglib2.0-0 libx11-xcb1 libxcb-dri3-0 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxi6 libxtst6 libnss3 libatk1.0-0 libdrm2 libgbm1 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libasound2 | grep installed 2> /dev/null | wc -l) != 20 ]; then
140146
# it's also possible we didn't see these in the list, because we have an out-of-date package list
@@ -153,6 +159,9 @@ if [ ! -f ~/.codeflare ] && [ $(uname) = Linux ]; then
153159
else
154160
touch ~/.codeflare
155161
fi
162+
163+
# our docker build uses this to do the apt initialization only
164+
if [ -n "$CODEFLARE_INIT_FOR_DOCKER" ]; then exit 0; fi
156165
fi
157166

158167
# helps with ctrl+c when running in a docker container

Dockerfile renamed to deploy/cli/Dockerfile

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1-
FROM ubuntu:latest
1+
FROM node:lts-slim
22

33
ENV DEBIAN_FRONTEND=noninteractive
4-
ENV PATH=/usr/local/CodeFlare/bin:$PATH
4+
ENV KUI_HEADLESS=true
5+
ENV KUI_HEADLESS_WEBPACK=true
6+
ENV CODEFLARE_HEADLESS_HOME=/usr/local/CodeFlare
57

68
# TODO hard-coded arch
7-
ADD dist/electron/CodeFlare-linux-x64 /usr/local/CodeFlare
9+
ADD dist/headless /usr/local/CodeFlare
10+
ADD store /usr/local/CodeFlare/store
11+
ADD bin/codeflare /usr/local/bin/codeflare
812

9-
# Note, the `codeflare ...` commands are not strictly necessary. We do
10-
# them here only to save some time installing these prereqs on every
11-
# run.
12-
RUN apt update && apt -y install python3 python3-pip \
13+
RUN apt update && apt -y install python3 python3-pip sudo curl \
1314
&& apt -y clean && rm -rf /var/lib/apt/lists/* \
14-
&& codeflare util/jq \
15-
&& codeflare util/websocat \
16-
&& codeflare s3/install/cli \
17-
&& codeflare ml/ray/install/cli \
18-
&& codeflare kubernetes/kubectl \
19-
&& codeflare kubernetes/helm3 \
15+
&& (cd /usr/bin && ln -s pip3 pip) \
2016
&& adduser --disabled-password --gecos '' codeflare && adduser codeflare sudo && adduser root sudo && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
21-
&& touch /home/codeflare/.codeflare
17+
&& mkdir -p /root/.local/share/madwizard-nodejs/profiles \
18+
&& codeflare -n util/jq \
19+
&& codeflare -n util/websocat \
20+
&& codeflare -n s3/install/cli \
21+
&& codeflare -n ml/ray/install/cli \
22+
&& codeflare -n kubernetes/kubectl \
23+
&& codeflare -n kubernetes/helm3
2224

23-
ENTRYPOINT ["codeflare"]
24-
WORKDIR /home/codeflare
2525
USER codeflare
26+
WORKDIR /home/codeflare
2627

27-
28-
28+
# Note, the `codeflare ...` commands are not strictly necessary. We do
29+
# them here only to save some time installing these prereqs on every
30+
# run.
2931

3032
# in case we want to use the published production versions at some point...
3133
#RUN export FILE=CodeFlare-linux-$([ "$(uname -m)" = "x86_64" ] && echo x64 || echo arm64) \

deploy/cli/codeflare.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: codeflare
5+
labels:
6+
app: codeflare
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: codeflare
12+
template:
13+
metadata:
14+
labels:
15+
app: codeflare
16+
spec:
17+
containers:
18+
- name: codeflare
19+
image: ghcr.io/project-codeflare/codeflare-cli

deploy/log-aggregator/Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM node:lts-slim
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
ENV KUI_HEADLESS=true
5+
ENV KUI_HEADLESS_WEBPACK=true
6+
ENV CODEFLARE_HEADLESS_HOME=/usr/local/CodeFlare
7+
8+
# TODO hard-coded arch
9+
ADD dist/headless /usr/local/CodeFlare
10+
ADD store /usr/local/CodeFlare/store
11+
ADD bin/codeflare /usr/local/bin/codeflare
12+
ADD deploy/log-aggregator/wait-for.sh /usr/local/bin/wait-for
13+
ADD deploy/log-aggregator/wait-for-and-cat.sh /usr/local/bin/wait-for-and-cat
14+
ADD deploy/log-aggregator/wait-for-and-tailf.sh /usr/local/bin/wait-for-and-tailf
15+
16+
# Note, the `codeflare ...` commands are not strictly necessary. We do
17+
# them here only to save some time installing these prereqs on every
18+
# run.
19+
RUN apt update && apt -y install sudo curl procps inotify-tools \
20+
&& apt -y clean && rm -rf /var/lib/apt/lists/* \
21+
&& adduser --disabled-password --gecos '' codeflare && adduser codeflare sudo && adduser root sudo && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
22+
&& mkdir -p /root/.local/share/madwizard-nodejs/profiles \
23+
&& codeflare -n util/jq \
24+
&& codeflare -n util/websocat \
25+
&& codeflare -n kubernetes/kubectl
26+
27+
USER codeflare
28+
WORKDIR /home/codeflare
29+
30+
CMD exec /bin/bash -c "trap : TERM INT; sleep infinity & wait"
31+
# ENTRYPOINT ["codeflare", "-y", "-p", "default", "ml/ray/aggregator/with-jobid"]
32+
33+
34+
# Notes
35+
# - KUBE_CONTEXT_ARG must be ""
36+
# - KUBE_NS_ARG can be "" for kubectl, but since we need it for RAY_ADDRESS, use the actual `-n ${KUBE_NS}` value
37+
# - RAY_ADDRESS must be of the form mycluster-ray-head.ray.svc.cluster.local:8265
38+
# $RAY_KUBE_CLUSTER_NAME.$KUBE_NS.svc.cluster.local:8265
39+
# ^^^^^^^ must be the actual namespace value
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
F="$1"
4+
5+
wait-for "$F" && cat "$F"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
F="$1"
4+
5+
wait-for "$F" && tail -f -n +1 "$F"

deploy/log-aggregator/wait-for.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
F="$1"
4+
5+
# wait for the file to exist and be non-empty
6+
while [ ! -s "$F" ]; do
7+
mkdir -p $(dirname $F)
8+
inotifywait -qq -e create -e modify "$(dirname $F)"
9+
done

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
"pty:nodejs": "npm run pty:rebuild node",
2020
"prepare": "cross-env husky install",
2121
"preprod": "npm run mirror",
22-
"build:docker0": "docker build -t ghcr.io/project-codeflare/codeflare-cli .",
23-
"build:docker": "NO_INSTALLER=true npm run build:electron:linux:amd64 && npm run build:docker0",
22+
"build:docker:cli": "npm run build:docker1 && docker build -f deploy/cli/Dockerfile -t ghcr.io/project-codeflare/codeflare-cli .",
23+
"build:docker:logs": "npm run build:docker1 && docker build -f deploy/log-aggregator/Dockerfile -t ghcr.io/project-codeflare/codeflare-log-aggregator .",
24+
"build:docker1": "if [ ! -n \"$FAST\" ]; then npm run build:docker0; fi",
25+
"build:docker0": "npm run mirror && CLIENT_HOME=$PWD webpack-cli --mode=${MODE-production} --config node_modules/@kui-shell/webpack/headless-webpack.config.js",
2426
"docker:debug": "ENTRYPOINT=bash ./bin/codeflare -d",
2527
"build:electron:mac:amd64": "npm run preprod && KUI_HEADLESS_WEBPACK=true KUI_LAUNCHER=$PWD/bin/codeflare PLATFORM=mac ARCH=x64 kui-build-electron",
2628
"build:electron:mac:arm64": "npm run preprod && KUI_HEADLESS_WEBPACK=true KUI_LAUNCHER=$PWD/bin/codeflare PLATFORM=mac ARCH=arm64 kui-build-electron",

0 commit comments

Comments
 (0)