|
| 1 | +# This Dockerfile enables an iterative development workflow where you can make |
| 2 | +# a change and test it out quickly. The majority of commands in this file will |
| 3 | +# be cached, making the feedback loop typically quite short. The workflow is |
| 4 | +# as follows: |
| 5 | +# 1. Set up pre-conditions for the system in puppet code using `deploy.pp`. |
| 6 | +# 2. Make a change to the module. |
| 7 | +# 3. Run `docker build -f docker/Dockerfile .` or |
| 8 | +# `./docker/bin/upgrade.sh rocky` from the project directory. If you would |
| 9 | +# like to test specific version upgrades, you can add run this like so: |
| 10 | +# `docker build -f docker/rocky/Dockerfile . \ |
| 11 | +# -t pa-dev:rocky --build-arg before=1.10.14` |
| 12 | +# 4. Upgrade the container by running the image: |
| 13 | +# `docker run -it pa-dev:rocky` |
| 14 | +# Specify your upgrade TO version as an argument to the `docker run` |
| 15 | +# command. |
| 16 | +# 5. Review the output. Repeat steps 2-5 as needed. |
| 17 | +# |
| 18 | +# At the end of execution, you will see a line like: |
| 19 | +# |
| 20 | +# Notice: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: ensure changed '1.10.14-1.el8' to '6.2.0' |
| 21 | +# |
| 22 | +# This specifies the versions that were used for upgrade. |
| 23 | +# |
| 24 | +# Arguments: |
| 25 | +# - before: The version to do upgrade FROM. Default: "7.34.0" |
| 26 | + |
| 27 | +FROM registry.suse.com/suse/sle15:15.6 |
| 28 | + |
| 29 | +# Use this to force a cache reset (e.g. for output purposes) |
| 30 | +#COPY $0 /tmp/Dockerfile |
| 31 | + |
| 32 | +# Install some other dependencies for ease of life. |
| 33 | +RUN zypper install --no-confirm wget git-core |
| 34 | + |
| 35 | +ARG before=7.34.0 |
| 36 | +LABEL before=${before} |
| 37 | + |
| 38 | +# Install proper FROM repo pupet 7 |
| 39 | +RUN if [[ ${before} == 7.* ]]; then \ |
| 40 | + wget -O puppet7.rpm http://yum.puppet.com/puppet7-release-sles-15.noarch.rpm && \ |
| 41 | + rpm -i puppet7.rpm; \ |
| 42 | + else echo no; \ |
| 43 | + fi |
| 44 | + |
| 45 | +# Install FROM version of puppet-agent. |
| 46 | +RUN rpm --import https://yum.puppet.com/RPM-GPG-KEY-puppet-20250406 && \ |
| 47 | + zypper install --no-confirm --oldpackage --no-recommends --no-confirm puppet-agent-${before} |
| 48 | + |
| 49 | +# This is also duplicated in the docker/bin/helpers/run-upgrade.sh. |
| 50 | +ENV module_path=/tmp/modules |
| 51 | +WORKDIR "${module_path}/puppet_agent" |
| 52 | +COPY metadata.json ./ |
| 53 | + |
| 54 | +# Dependency installation: Forge or source? The former is what the user will |
| 55 | +# have downloaded, but the latter allows testing of version bumps. |
| 56 | +# Install module dependencies from the Forge using Puppet Module Tool (PMT). |
| 57 | +RUN /opt/puppetlabs/puppet/bin/puppet module install --modulepath $module_path --target-dir .. puppetlabs-stdlib |
| 58 | +RUN /opt/puppetlabs/puppet/bin/puppet module install --modulepath $module_path --target-dir .. puppetlabs-inifile |
| 59 | +RUN /opt/puppetlabs/puppet/bin/puppet module install --modulepath $module_path --target-dir .. puppetlabs-apt |
| 60 | +RUN /opt/puppetlabs/puppet/bin/puppet module install --modulepath $module_path --target-dir .. puppetlabs-facts |
| 61 | + |
| 62 | +# Installing dependencies from source. These versions should be within the range |
| 63 | +# of `dependencies` in metadata.json. |
| 64 | +#RUN git clone https://github.com/puppetlabs/puppetlabs-stdlib ../stdlib --branch 9.7.0 |
| 65 | +#RUN git clone https://github.com/puppetlabs/puppetlabs-inifile ../inifile --branch 6.2.0 |
| 66 | +#RUN git clone https://github.com/puppetlabs/puppetlabs-apt ../apt --branch 10.0.1 |
| 67 | +#RUN git clone https://github.com/puppetlabs/puppetlabs-facts ../facts --branch 1.7.0 |
| 68 | + |
| 69 | +# Check that all dependencies are installed. |
| 70 | +RUN /opt/puppetlabs/puppet/bin/puppet module --modulepath $module_path list --tree |
| 71 | +COPY docker/deploy.pp /tmp/deploy.pp |
| 72 | +RUN ["sh", "-c", "/opt/puppetlabs/puppet/bin/puppet apply --modulepath $module_path /tmp/deploy.pp"] |
| 73 | + |
| 74 | +# Now move the project directory's files into the image. That way, if these |
| 75 | +# files change, caching will skip everything before this. |
| 76 | +COPY docker/bin/helpers/run-upgrade.sh /tmp/bin/run-upgrade.sh |
| 77 | +COPY files/ ./files/ |
| 78 | +COPY locales/ ./locales/ |
| 79 | +COPY spec/ ./spec/ |
| 80 | +COPY task_spec/ ./task_spec/ |
| 81 | +COPY tasks/ ./tasks/ |
| 82 | +COPY templates/ ./templates |
| 83 | +COPY types/ ./types/ |
| 84 | +COPY Gemfile Gemfile.lock Rakefile ./ |
| 85 | +COPY lib/ ./lib/ |
| 86 | +COPY manifests/ ./manifests/ |
| 87 | + |
| 88 | +COPY docker/upgrade.pp /tmp/upgrade.pp |
| 89 | + |
| 90 | +# Perform the upgrade. |
| 91 | +ENTRYPOINT ["/tmp/bin/run-upgrade.sh"] |
0 commit comments