Skip to content

Commit

Permalink
feat: reverse engineer build from install.sh and Makefile
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Waffen <[email protected]>
  • Loading branch information
rwaffen committed Oct 9, 2024
1 parent fb38a85 commit be3577b
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 40 deletions.
2 changes: 2 additions & 0 deletions build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
puppet-*
puppetserver-*
91 changes: 61 additions & 30 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,71 @@
FROM openjdk:24-bullseye

ENV opt_dir=/opt/puppetlabs/server/apps/puppetserver
ENV etc_dir=/etc/puppetlabs/puppetserver
ADD puppetserver-8.6.3 /install

WORKDIR $opt_dir
ENV apps_dir=/opt/puppetlabs/server/apps
ENV app_logdir=/var/log/puppetlabs/puppetserver
ENV data_dir=/opt/puppetlabs/server/data
ENV etc_dir=/etc/puppetlabs
ENV rundir=/var/run/puppetlabs/puppetserver
ENV bindir=/opt/puppetlabs/server/apps/puppetserver/bin
ENV symbindir=/opt/puppetlabs/server/bin
ENV uxbindir=/opt/puppetlabs/bin

COPY puppet-server-release.jar $opt_dir/puppet-server-release.jar
RUN cd /install \
&& install -d -m 0755 "${apps_dir}/puppetserver" \
&& install -d -m 0770 "${data_dir}/puppetserver" \
&& install -m 0644 puppet-server-release.jar "${apps_dir}/puppetserver" \
&& install -m 0774 ext/ezbake-functions.sh "${apps_dir}/puppetserver" \
&& install -m 0644 ext/ezbake.manifest "${apps_dir}/puppetserver" \
&& install -d -m 0755 "${etc_dir}/puppetserver/conf.d" \
&& install -d -m 0755 "${etc_dir}/puppetserver/services.d" \
&& install -m 0644 ext/config/request-logging.xml "${etc_dir}/puppetserver/request-logging.xml" \
&& install -m 0644 ext/config/conf.d/puppetserver.conf "${etc_dir}/puppetserver/conf.d/puppetserver.conf" \
&& install -m 0644 ext/config/logback.xml "${etc_dir}/puppetserver/logback.xml" \
&& install -m 0644 ext/config/services.d/ca.cfg "${etc_dir}/puppetserver/services.d/ca.cfg" \
&& install -m 0644 ext/config/conf.d/global.conf "${etc_dir}/puppetserver/conf.d/global.conf" \
&& install -m 0644 ext/config/conf.d/web-routes.conf "${etc_dir}/puppetserver/conf.d/web-routes.conf" \
&& install -m 0644 ext/config/conf.d/auth.conf "${etc_dir}/puppetserver/conf.d/auth.conf" \
&& install -m 0644 ext/config/conf.d/metrics.conf "${etc_dir}/puppetserver/conf.d/metrics.conf" \
&& install -m 0644 ext/config/conf.d/ca.conf "${etc_dir}/puppetserver/conf.d/ca.conf" \
&& install -m 0644 ext/config/conf.d/webserver.conf "${etc_dir}/puppetserver/conf.d/webserver.conf" \
&& install -d -m 0755 "${apps_dir}/puppetserver/cli" \
&& install -d -m 0755 "${apps_dir}/puppetserver/cli/apps" \
&& install -d -m 0755 "${bindir}" \
&& install -d -m 0755 "${symbindir}" \
&& install -d -m 0755 "${uxbindir}" \
&& install -m 0755 "ext/bin/puppetserver" "${bindir}/puppetserver" \
&& ln -s "../apps/puppetserver/bin/puppetserver" "${symbindir}/puppetserver" \
&& ln -s "../server/apps/puppetserver/bin/puppetserver" "${uxbindir}/puppetserver" \
&& install -m 0755 ext/cli/foreground "${apps_dir}/puppetserver/cli/apps/foreground" \
&& install -m 0755 ext/cli/dropsonde "${apps_dir}/puppetserver/cli/apps/dropsonde" \
&& install -m 0755 ext/cli/ca "${apps_dir}/puppetserver/cli/apps/ca" \
&& install -m 0755 ext/cli/irb "${apps_dir}/puppetserver/cli/apps/irb" \
&& install -m 0755 ext/cli/gem "${apps_dir}/puppetserver/cli/apps/gem" \
&& install -m 0755 ext/cli/reload "${apps_dir}/puppetserver/cli/apps/reload" \
&& install -m 0755 ext/cli/ruby "${apps_dir}/puppetserver/cli/apps/ruby" \
&& install -m 0755 ext/cli/stop "${apps_dir}/puppetserver/cli/apps/stop" \
&& install -m 0755 ext/cli/start "${apps_dir}/puppetserver/cli/apps/start" \
&& install -m 0644 puppet-server-release.jar "${apps_dir}/puppetserver" \
&& install -d -m 0700 "${app_logdir}" \
&& install -d -m 0755 "${rundir}" \
&& install -d -m 700 "${data_dir}/puppetserver/jars" \
&& install -d -m 700 "${data_dir}/puppetserver/yaml"

COPY ext/cli $opt_dir/cli/apps
COPY ext/cli_defaults/cli-defaults.sh $opt_dir/cli/cli-defaults.sh
COPY ext/bin $opt_dir/bin
COPY ext/bin/puppetserver /opt/puppetlabs/bin/puppetserver
COPY ext/ezbake-functions.sh $opt_dir/ezbake-functions.sh
COPY install.sh $opt_dir/scripts/install.sh
RUN echo 'alias ll="ls -la --color=auto"' >> ~/.bashrc

COPY ext/ezbake.manifest $opt_dir/ezbake.manifest
COPY ext/system-config/services.d/bootstrap.cfg $opt_dir/config/services.d/bootstrap.cfg
COPY ext/config/conf.d $etc_dir/conf.d
COPY ext/config/services.d $etc_dir/services.d
COPY ext/default /etc/default/puppetserver

COPY ext/config/logback.xml \
ext/config/request-logging.xml \
${etc_dir}

RUN useradd --uid 1001 --home-dir ${opt_dir} --shell /usr/sbin/nologin --user-group puppet \
&& chown -R puppet:puppet /opt/puppetlabs \
&& chown -R puppet:puppet /etc/puppetlabs \
&& chmod +x /opt/puppetlabs/bin/* \
&& chmod +x ${opt_dir}/bin/* \
&& chmod +x ${opt_dir}/cli/**/* \
&& chmod +x ${opt_dir}/scripts/* \
&& chmod +x ${opt_dir}/ezbake-functions.sh \
RUN useradd --uid 1001 --home-dir ${data_dir}/puppetserver --shell /usr/sbin/nologin --user-group puppet \
&& install --owner=puppet --group=puppet -d /opt/puppetlabs/server/data/puppetserver/jruby-gems \
&& install --directory --owner=puppet --group=puppet --mode=775 /opt/puppetlabs/server/data \
&& install --directory "${etc_dir}/puppet/ssl" \
&& install --directory "${etc_dir}/puppetserver/ca" \
&& chown -R puppet:puppet ${etc_dir}/puppet/ssl \
&& chown -R puppet:puppet ${etc_dir}/puppetserver/ca \
&& find /etc/puppetlabs/puppet/ssl -type d -print0 | xargs -0 chmod 770 \
&& ln -s /usr/local/openjdk-24/bin/java /usr/bin/java
# && /opt/puppetlabs/bin/puppetserver gem install puppet

EXPOSE 8140

ENTRYPOINT ["/opt/puppetlabs/bin/puppetserver"]
CMD ["start"]
# ENTRYPOINT ["/opt/puppetlabs/bin/puppetserver"]
# CMD ["start"]
32 changes: 22 additions & 10 deletions build/build.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
#!/bin/bash

software_version=${1:-8.6.2}
container_version=${2:-1.0.0}
pps_version=${1:-8.6.3}
pp_version=${2:-8.9.0}
container_version=${3:-1.0.1}

curl -v https://downloads.puppet.com/puppet/puppetserver-${software_version}.tar.gz -o puppetserver-${software_version}.tar.gz
tar -xvf puppetserver-${software_version}.tar.gz
if [ -d puppetserver-${pps_version} ]; then
rm -rf puppetserver-${pps_version}
fi

cp Dockerfile puppetserver-${software_version}/
cd puppetserver-${software_version}
docker build -t puppetserver:${software_version}-v${container_version} .
if [ -d puppet-${pp_version} ]; then
rm -rf puppet-${pp_version}
fi

cd -
rm -rf puppetserver-${software_version}
rm puppetserver-${software_version}.tar.gz
if [ ! -f puppetserver-${pps_version}.tar.gz ]; then
curl -v https://downloads.puppet.com/puppet/puppetserver-${pps_version}.tar.gz -o puppetserver-${pps_version}.tar.gz
fi
if [ ! -f puppet-${pp_version}.tar.gz ]; then
curl -v https://downloads.puppet.com/puppet/puppet-${pp_version}.tar.gz -o puppet-${pp_version}.tar.gz
fi

tar -xf puppetserver-${pps_version}.tar.gz
tar -xf puppet-${pp_version}.tar.gz

# cp Dockerfile puppetserver-${pps_version}/
# cd puppetserver-${pps_version}
docker build -t puppetserver:${pps_version}-v${container_version} .

0 comments on commit be3577b

Please sign in to comment.