|
| 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: "1.10.14" |
| 26 | + |
| 27 | +FROM rockylinux/rockylinux:8 |
| 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 dnf update -y \ |
| 34 | + && dnf install -y wget git \ |
| 35 | + && dnf clean all |
| 36 | + |
| 37 | +ARG before=1.10.14 |
| 38 | +LABEL before=${before} |
| 39 | + |
| 40 | +# Install proper FROM repo: puppet 6 or puppet 7. |
| 41 | +RUN if [[ ${before} == 6.* ]]; then \ |
| 42 | + echo Installing puppet6 repo; \ |
| 43 | + wget -O puppet6.rpm http://yum.puppet.com/puppet6-release-el-8.noarch.rpm && \ |
| 44 | + rpm -i puppet6.rpm; \ |
| 45 | + elif [[ ${before} == 7.* ]]; then \ |
| 46 | + echo Installing puppet7 repo; \ |
| 47 | + wget -O puppet7.rpm http://yum.puppet.com/puppet7-release-el-8.noarch.rpm && \ |
| 48 | + rpm -i puppet7.rpm; \ |
| 49 | + else echo no; \ |
| 50 | + fi |
| 51 | + |
| 52 | +# Print out which versions of the puppet-agent package are available (for reference). |
| 53 | +#RUN dnf list puppet-agent --showduplicates |
| 54 | + |
| 55 | +# Install FROM version of puppet-agent. |
| 56 | +RUN dnf -y update && \ |
| 57 | + dnf install -y puppet-agent-${before}-1.el8 |
| 58 | + |
| 59 | +# This is also duplicated in the docker/bin/helpers/run-upgrade.sh. |
| 60 | +ENV module_path=/tmp/modules |
| 61 | +WORKDIR "${module_path}/puppet_agent" |
| 62 | +COPY metadata.json ./ |
| 63 | + |
| 64 | +# Dependency installation: Forge or source? The former is what the user will |
| 65 | +# have downloaded, but the latter allows testing of version bumps. |
| 66 | +# Install module dependencies from the Forge using Puppet Module Tool (PMT). |
| 67 | +RUN /opt/puppetlabs/puppet/bin/puppet module install --modulepath $module_path --target-dir .. puppetlabs-stdlib |
| 68 | +RUN /opt/puppetlabs/puppet/bin/puppet module install --modulepath $module_path --target-dir .. puppetlabs-inifile |
| 69 | +RUN /opt/puppetlabs/puppet/bin/puppet module install --modulepath $module_path --target-dir .. puppetlabs-apt |
| 70 | + |
| 71 | +# Installing dependencies from source. These versions should be within the range |
| 72 | +# of `dependencies` in metadata.json. `translate` is a dependency for inifile. |
| 73 | +#RUN git clone https://github.com/puppetlabs/puppetlabs-stdlib ../stdlib --branch 5.2.0 |
| 74 | +#RUN git clone https://github.com/puppetlabs/puppetlabs-inifile ../inifile --branch 2.5.0 |
| 75 | +#RUN git clone https://github.com/puppetlabs/puppetlabs-translate ../translate --branch 1.2.0 |
| 76 | +#RUN git clone https://github.com/puppetlabs/puppetlabs-apt ../apt --branch 6.3.0 |
| 77 | + |
| 78 | +# Check that all dependencies are installed. |
| 79 | +RUN /opt/puppetlabs/puppet/bin/puppet module --modulepath $module_path list --tree |
| 80 | +COPY docker/deploy.pp /tmp/deploy.pp |
| 81 | +RUN ["sh", "-c", "/opt/puppetlabs/puppet/bin/puppet apply --modulepath $module_path /tmp/deploy.pp"] |
| 82 | + |
| 83 | +# Now move the project directory's files into the image. That way, if these |
| 84 | +# files change, caching will skip everything before this. |
| 85 | +COPY docker/bin/helpers/run-upgrade.sh /tmp/bin/run-upgrade.sh |
| 86 | +COPY files/ ./files/ |
| 87 | +COPY locales/ ./locales/ |
| 88 | +COPY spec/ ./spec/ |
| 89 | +COPY task_spec/ ./task_spec/ |
| 90 | +COPY tasks/ ./tasks/ |
| 91 | +COPY templates/ ./templates |
| 92 | +COPY types/ ./types/ |
| 93 | +COPY Gemfile Gemfile.lock Rakefile ./ |
| 94 | +COPY lib/ ./lib/ |
| 95 | +COPY manifests/ ./manifests/ |
| 96 | + |
| 97 | +COPY docker/upgrade.pp /tmp/upgrade.pp |
| 98 | + |
| 99 | +# Print out which versions of the puppet-agent package are available (for reference). |
| 100 | +#RUN yum list puppet-agent --showduplicates |
| 101 | + |
| 102 | +# Perform the upgrade. |
| 103 | +ENTRYPOINT ["/tmp/bin/run-upgrade.sh"] |
0 commit comments