Closed sanfrancrisko closed 3 years ago
Thanks to @michaeltlombardi for the prior work and write up on #164 , I was able to get a container up and running without too much hassle
I started with the Ruby 2.7-slim
Dockerfile and then tweaked to:
build-essential
, git
pdk
diff --git b/Dockerfile.original a/Dockerfile
index 1042aa3..ca4e68d 100644
--- a/Dockerfile.original
+++ b/Dockerfile
@@ -9,10 +9,8 @@ FROM debian:bullseye-slim
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
+ build-essential \
bzip2 \
ca-certificates \
+ git \
libffi-dev \
libgmp-dev \
libssl-dev \
@@ -120,7 +118,3 @@ ENV BUNDLE_SILENCE_ROOT_WARNING=1 \
ENV PATH $GEM_HOME/bin:$PATH
# adjust permissions of a few directories for running "gem install" as an arbitrary user
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
+RUN gem install pdk
+
+ENTRYPOINT ["/usr/local/bundle/bin/pdk"]
+CMD ["validate"]
Following @michaeltlombardi's example, I then ran pdk validate
on the puppetlabs-motd
module:
docker run -v ${PWD}:/module -w /module pdkdocker
The image size (entirely unoptimized) is 422MB.
It is also possible to install any/all native compiled gems, including pry.
I also experimented with calling gem install puppet-strings puppet-lint
, which then allowed me to call puppet strings
and puppet-lint
as expected.
Similar pros/cons @michaeltlombardi reported in #164 apply here, along with some unique issues:
Some unique cons to this solution:
2021-06-25
: Ruby 2.5 removed due to it being EOL'd2020-04-13
: Ruby 2.4 removed due to it being EOL'dThis was a relatively simple solution to assemble, I think issue of upstream base images disappearing from us before we're ready to EOL support on our side, adds a bit more complexity compared to #164, however, the Ruby builds are still available here, the older Dockerfiles can be located here, so we could certainly continue to maintain these ourselves, if needs be.
The fact we're not using the same flavour of Ruby as the agent is probably going to be the question we need to answer before continuing in attempting to productionise this solution more.