Skip to content

Commit a47ee8a

Browse files
committed
fix: added k8s runtime
1 parent 0314ef5 commit a47ee8a

3 files changed

Lines changed: 166 additions & 0 deletions

File tree

salami/clinc-server/15/Dockerfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
FROM ubuntu:22.04
2+
3+
ENV container=docker
4+
5+
# Systemd + basics + tzdata
6+
RUN apt-get update && \
7+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
8+
systemd systemd-sysv \
9+
dbus \
10+
curl ca-certificates bash locales iproute2 \
11+
tzdata \
12+
cron && \
13+
rm -rf /var/lib/apt/lists/*
14+
15+
# Ensure cron hourly directory exists (infra-server::log_cleanup expects it)
16+
RUN mkdir -p /etc/cron.hourly
17+
18+
# Locale
19+
RUN sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen && \
20+
locale-gen
21+
22+
ENV LANG=en_US.UTF-8 \
23+
LANGUAGE=en_US:en \
24+
LC_ALL=en_US.UTF-8 \
25+
TZ=UTC
26+
27+
# Set timezone files so tzdata / Perl can resolve it
28+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
29+
echo $TZ > /etc/timezone
30+
31+
# Basic hostname/hosts for Ohai
32+
RUN echo "cinc-server" > /etc/hostname && \
33+
printf "127.0.0.1 localhost cinc-server\n::1 localhost ip6-localhost ip6-loopback\n" > /etc/hosts
34+
35+
# Install Cinc Server (amd64)
36+
RUN curl -L https://omnitruck.cinc.sh/install.sh -o /tmp/install-cinc.sh && \
37+
chmod +x /tmp/install-cinc.sh && \
38+
bash /tmp/install-cinc.sh -P cinc-server && \
39+
rm -f /tmp/install-cinc.sh
40+
41+
# Optional: initial config tweak so postgres listen_address doesn't depend on Ohai
42+
RUN mkdir -p /etc/opscode && \
43+
printf "postgresql['listen_address'] = '127.0.0.1'\n" > /etc/opscode/private-chef.rb
44+
45+
# Stub partybus config.rb to satisfy infra-server::partybus in container
46+
RUN mkdir -p /opt/cinc-project/embedded/service/partybus && \
47+
printf '%s\n' \
48+
'# Minimal stub Partybus config for container lab' \
49+
'module Partybus' \
50+
' class Config' \
51+
' def self.config' \
52+
' @config ||= {}' \
53+
' end' \
54+
' end' \
55+
'end' \
56+
> /opt/cinc-project/embedded/service/partybus/config.rb
57+
58+
EXPOSE 443
59+
60+
STOPSIGNAL SIGRTMIN+3
61+
VOLUME ["/sys/fs/cgroup", "/run", "/run/lock"]
62+
63+
CMD ["/sbin/init"]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Basic trap to forward signals to cinc-server-ctl for graceful shutdown
5+
_term() {
6+
echo "[entrypoint] Caught SIGTERM, stopping Cinc Server..." >&2
7+
cinc-server-ctl stop || true
8+
exit 0
9+
}
10+
11+
trap _term TERM INT
12+
13+
BOOTSTRAP_FLAG="/etc/opscode/.bootstrapped"
14+
15+
# If config is not bootstrapped yet, run reconfigure (idempotent)
16+
if [ ! -f "$BOOTSTRAP_FLAG" ]; then
17+
echo "[entrypoint] Running initial cinc-server-ctl reconfigure..." >&2
18+
cinc-server-ctl reconfigure
19+
touch "$BOOTSTRAP_FLAG"
20+
fi
21+
22+
# Allow overriding default behavior via args (for debugging, etc.)
23+
if [ "${1:-}" = "bash" ]; then
24+
exec bash
25+
fi
26+
27+
# Start all services
28+
echo "[entrypoint] Starting Cinc Server services..." >&2
29+
cinc-server-ctl start
30+
31+
# Simple wait loop: tail nginx log so the container stays alive
32+
LOG_FILE="/var/log/opscode/nginx/current"
33+
34+
if [ -f "$LOG_FILE" ]; then
35+
echo "[entrypoint] Tailing $LOG_FILE" >&2
36+
exec tail -F "$LOG_FILE"
37+
else
38+
echo "[entrypoint] Log file $LOG_FILE not found, sleeping..." >&2
39+
# Fallback: sleep loop
40+
while true; do
41+
sleep 3600 &
42+
wait $!
43+
done
44+
fi
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
# Minimal systemctl shim for Omnibus/Cinc Server inside Kubernetes.
3+
# It pretends that certain units exist and are active/enabled so
4+
# Chef's Systemd provider is satisfied, but does NOT manage real services.
5+
6+
set -euo pipefail
7+
8+
echo "[systemctl-shim] systemctl $*" >&2
9+
10+
SUBCMD=""
11+
UNIT=""
12+
13+
# Very simple argument parser: first arg = subcommand, first non-flag after that = unit
14+
for arg in "$@"; do
15+
if [ -z "$SUBCMD" ]; then
16+
SUBCMD="$arg"
17+
elif [ -z "$UNIT" ] && [[ "$arg" != -* ]]; then
18+
UNIT="$arg"
19+
break
20+
fi
21+
done
22+
23+
case "$SUBCMD" in
24+
daemon-reload)
25+
# No-op
26+
exit 0
27+
;;
28+
enable|disable|start|stop|restart|reload)
29+
# Pretend these always work
30+
exit 0
31+
;;
32+
is-enabled)
33+
# Pretend everything is enabled
34+
exit 0
35+
;;
36+
is-active)
37+
# Pretend everything is active
38+
exit 0
39+
;;
40+
show)
41+
# Chef's Systemd provider calls `systemctl show <unit> ...` and expects
42+
# some properties. We fake a minimal, always-active unit.
43+
if [ -n "$UNIT" ]; then
44+
cat <<EOF
45+
Id=$UNIT
46+
Names=$UNIT
47+
LoadState=loaded
48+
ActiveState=active
49+
SubState=running
50+
UnitFileState=enabled
51+
EOF
52+
fi
53+
exit 0
54+
;;
55+
*)
56+
# Default: succeed
57+
exit 0
58+
;;
59+
esac

0 commit comments

Comments
 (0)