-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
146 lines (119 loc) · 4.48 KB
/
Dockerfile
File metadata and controls
146 lines (119 loc) · 4.48 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
# Multi-stage Dockerfile for puppet_c
# Usage:
# docker build --target compiler -t puppetc-compile .
# docker build --target server -t puppetc-server .
# docker build --target agent -t puppetc-agent .
# =============================================================================
# Build stage - creates .deb packages
# =============================================================================
FROM debian:bookworm AS builder
RUN apt-get update && apt-get install -y \
build-essential \
autoconf \
automake \
libtool \
gawk \
pkg-config \
libtree-sitter-dev \
libyaml-dev \
libssl-dev \
libmicrohttpd-dev \
libcurl4-openssl-dev \
libsqlite3-dev \
ruby-dev \
debhelper \
devscripts \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
COPY . .
# Build Debian packages
RUN autoreconf -i && \
dpkg-buildpackage -us -uc -b
# Move packages to a known location
RUN mkdir -p /packages && mv /puppet-c*.deb /lib*.deb /packages/ 2>/dev/null || mv ../*.deb /packages/
# =============================================================================
# Server image
# =============================================================================
FROM debian:bookworm-slim AS server
RUN apt-get update && apt-get install -y --no-install-recommends \
libtree-sitter0 \
libyaml-0-2 \
libssl3 \
libmicrohttpd12 \
libsqlite3-0 \
libruby3.1 \
curl \
openssl \
&& rm -rf /var/lib/apt/lists/*
# Copy and install packages
COPY --from=builder /packages/libpuppetc-common0_*.deb /tmp/
COPY --from=builder /packages/libfacter-c0_*.deb /tmp/
COPY --from=builder /packages/libpuppetc0_*.deb /tmp/
COPY --from=builder /packages/puppetc-server_*.deb /tmp/
RUN dpkg -i /tmp/libpuppetc-common0_*.deb \
/tmp/libfacter-c0_*.deb \
/tmp/libpuppetc0_*.deb \
/tmp/puppetc-server_*.deb && \
rm -rf /tmp/*.deb
# Create puppet directories and PuppetDB directory
RUN mkdir -p /etc/puppet/manifests /etc/puppet/modules /etc/puppet/hiera /var/lib/puppetc
# Create SSL certificate directories
RUN mkdir -p /etc/puppetc/ssl/ca /etc/puppetc/ssl/certs /etc/puppetc/ssl/private
# Enable naive autosigning for development (auto-signs all CSRs)
RUN mkdir -p /etc/puppetc && printf '[autosign]\nmode = naive\n' > /etc/puppetc/autosign.conf
EXPOSE 8140
ENTRYPOINT ["puppetc-server"]
CMD ["-v", "-m", "/etc/puppet/modules", "-D", "/etc/puppet/hiera", "-C", "/etc/puppetc/ssl/ca", "/etc/puppet"]
# =============================================================================
# Agent image
# =============================================================================
FROM debian:bookworm-slim AS agent
RUN apt-get update && apt-get install -y --no-install-recommends \
libcurl4 \
libsqlite3-0 \
ca-certificates \
cron \
bash \
libruby3.1 \
openssl \
&& rm -rf /var/lib/apt/lists/*
# Copy and install packages
COPY --from=builder /packages/libpuppetc-common0_*.deb /tmp/
COPY --from=builder /packages/libfacter-c0_*.deb /tmp/
COPY --from=builder /packages/puppetc-agent_*.deb /tmp/
RUN dpkg -i /tmp/libpuppetc-common0_*.deb \
/tmp/libfacter-c0_*.deb \
/tmp/puppetc-agent_*.deb && \
rm -rf /tmp/*.deb
# Create SSL certificate directories
RUN mkdir -p /var/lib/puppetc/ssl/ca /var/lib/puppetc/ssl/certs /var/lib/puppetc/ssl/private_keys
ENTRYPOINT ["puppetc-agent"]
# Default: noop mode. Use -a to apply.
# Set PUPPET_SERVER env var or use -s to specify server.
CMD ["-n"]
# =============================================================================
# Compiler image - for local development and CI/CD
# =============================================================================
FROM debian:bookworm-slim AS compiler
RUN apt-get update && apt-get install -y --no-install-recommends \
libtree-sitter0 \
libyaml-0-2 \
libssl3 \
libsqlite3-0 \
libruby3.1 \
&& rm -rf /var/lib/apt/lists/*
# Copy and install packages
COPY --from=builder /packages/libpuppetc-common0_*.deb /tmp/
COPY --from=builder /packages/libpuppetc0_*.deb /tmp/
COPY --from=builder /packages/libfacter-c0_*.deb /tmp/
COPY --from=builder /packages/puppetc_*.deb /tmp/
RUN dpkg -i /tmp/libpuppetc-common0_*.deb \
/tmp/libpuppetc0_*.deb \
/tmp/libfacter-c0_*.deb \
/tmp/puppetc_*.deb && \
rm -rf /tmp/*.deb
# Create puppet directories
RUN mkdir -p /puppet/manifests /puppet/modules /puppet/hiera /puppet/facts
WORKDIR /puppet
ENTRYPOINT ["puppetc-compile"]
CMD ["--help"]