Skip to content

Commit 3f9443d

Browse files
committed
feat: dockerfile
1 parent db36ee9 commit 3f9443d

1 file changed

Lines changed: 105 additions & 0 deletions

File tree

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
FROM ubuntu:22.04
2+
3+
# Minimal base for running Cinc Server in a container/Kubernetes (no systemd)
4+
RUN apt-get update && \
5+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
6+
curl ca-certificates bash locales iproute2 \
7+
tzdata \
8+
cron && \
9+
rm -rf /var/lib/apt/lists/*
10+
11+
# Ensure cron hourly directory exists (infra-server::log_cleanup expects it)
12+
RUN mkdir -p /etc/cron.hourly
13+
14+
# Locale
15+
RUN sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen && \
16+
locale-gen
17+
18+
ENV LANG=en_US.UTF-8 \
19+
LANGUAGE=en_US:en \
20+
LC_ALL=en_US.UTF-8 \
21+
TZ=UTC
22+
23+
# Set timezone files so tzdata / Perl can resolve it
24+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
25+
echo $TZ > /etc/timezone
26+
27+
# Basic hostname/hosts for Ohai (can be overridden by Kubernetes)
28+
RUN echo "cinc-server" > /etc/hostname && \
29+
printf "127.0.0.1 localhost cinc-server\n::1 localhost ip6-localhost ip6-loopback\n" > /etc/hosts
30+
31+
# Install Cinc Server (amd64)
32+
RUN curl -L https://omnitruck.cinc.sh/install.sh -o /tmp/install-cinc.sh && \
33+
chmod +x /tmp/install-cinc.sh && \
34+
bash /tmp/install-cinc.sh -P cinc-server && \
35+
rm -f /tmp/install-cinc.sh
36+
37+
# Optional: initial config tweak so postgres listen_address doesn't depend on Ohai
38+
RUN mkdir -p /etc/opscode && \
39+
cat > /etc/opscode/private-chef.rb <<'EOF'
40+
postgresql['listen_address'] = '127.0.0.1'
41+
42+
# /etc/opscode/private-chef.rb
43+
44+
postgresql['listen_address'] = '127.0.0.1'
45+
46+
begin
47+
class Chef
48+
class Resource
49+
class ComponentRunitSupervisor < Chef::Resource
50+
resource_name :component_runit_supervisor
51+
52+
default_action :create
53+
allowed_actions :create
54+
55+
property :name, String, name_property: true
56+
57+
action :create do
58+
Chef::Log.warn("component_runit_supervisor[\#{name}] no-op in k8s image (no real systemd)")
59+
# Do nothing: rely on docker-entrypoint.sh and runit
60+
end
61+
end
62+
end
63+
end
64+
rescue StandardError => e
65+
Chef::Log.warn("Failed to override component_runit_supervisor: \#{e}")
66+
end
67+
EOF
68+
69+
RUN cat /etc/opscode/private-chef.rb
70+
# Support external Postgres via environment variables if desired
71+
# (Typically you will mount a ConfigMap/Secret with a full private-chef.rb instead.)
72+
# These envs are hints; real config should live in private-chef.rb.
73+
ENV PGHOST="" \
74+
PGPORT="5432" \
75+
PGUSER="" \
76+
PGPASSWORD="" \
77+
PGSSLMODE="prefer"
78+
79+
# Stub partybus config.rb to satisfy infra-server::partybus in container
80+
RUN mkdir -p /opt/cinc-project/embedded/service/partybus && \
81+
printf '%s\n' \
82+
'# Minimal stub Partybus config for container/Kubernetes' \
83+
'module Partybus' \
84+
' class Config' \
85+
' def self.config' \
86+
' @config ||= {}' \
87+
' end' \
88+
' end' \
89+
'end' \
90+
> /opt/cinc-project/embedded/service/partybus/config.rb
91+
92+
# Minimal systemctl shim so omnibus cookbooks that call
93+
# 'systemctl daemon-reload' don't fail. This does NOT run real systemd.
94+
COPY systemctl-shim.sh /usr/local/bin/systemctl
95+
RUN chmod +x /usr/local/bin/systemctl && \
96+
ln -s /usr/local/bin/systemctl /bin/systemctl
97+
98+
# Simple entrypoint: reconfigure once (idempotent) then start services
99+
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
100+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
101+
102+
EXPOSE 443
103+
104+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
105+
CMD ["foreground"]

0 commit comments

Comments
 (0)