|
| 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 | +ARG BASE_IMAGE=ubuntu:noble |
| 28 | +FROM ${BASE_IMAGE} |
| 29 | + |
| 30 | +# Use this to force a cache reset (e.g. for output purposes) |
| 31 | +#COPY $0 /tmp/Dockerfile |
| 32 | + |
| 33 | +# Install some other dependencies for ease of life. |
| 34 | +RUN apt-get update \ |
| 35 | + && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y wget git lsb-release apt-utils systemd gnupg \ |
| 36 | + && rm -rf /var/lib/apt/lists/* |
| 37 | + |
| 38 | +ARG before=7.34.0 |
| 39 | +LABEL before=${before} |
| 40 | + |
| 41 | +ARG RELEASE_PACKAGE |
| 42 | + |
| 43 | +RUN apt-get update \ |
| 44 | + && apt install -y curl \ |
| 45 | + && rm -rf /var/lib/apt/lists/* |
| 46 | + |
| 47 | +# Install proper FROM repo pupet 7 |
| 48 | +RUN curl -L -o puppet7.deb ${RELEASE_PACKAGE} \ |
| 49 | + && dpkg -i puppet7.deb |
| 50 | + |
| 51 | +# Print out which versions of the puppet-agent package are available (for reference). |
| 52 | +#RUN dnf list puppet-agent --showduplicates |
| 53 | + |
| 54 | +# Install FROM version of puppet-agent. |
| 55 | +RUN apt-get update \ |
| 56 | + && apt list -a puppet-agent \ |
| 57 | + && DEBIAN_FRONTEND=noninteractive apt-get install -y puppet-agent \ |
| 58 | + && rm -rf /var/lib/apt/lists/* |
| 59 | + |
| 60 | +# This is also duplicated in the docker/bin/helpers/run-upgrade.sh. |
| 61 | +ENV module_path=/tmp/modules |
| 62 | +WORKDIR "${module_path}/puppet_agent" |
| 63 | +COPY metadata.json ./ |
| 64 | + |
| 65 | +# Installing dependencies from source. These versions should be within the range |
| 66 | +# of `dependencies` in metadata.json. |
| 67 | +RUN git clone --tags https://github.com/puppetlabs/puppetlabs-stdlib ../stdlib && \ |
| 68 | + $(cd ../stdlib && git checkout $(git describe --tags $(git rev-list --tags --max-count=1))) |
| 69 | +RUN git clone --tags https://github.com/puppetlabs/puppetlabs-inifile ../inifile && \ |
| 70 | + $(cd ../inifile && git checkout $(git describe --tags $(git rev-list --tags --max-count=1))) |
| 71 | +RUN git clone --tags https://github.com/puppetlabs/puppetlabs-apt ../apt && \ |
| 72 | + $(cd ../apt && git checkout $(git describe --tags $(git rev-list --tags --max-count=1))) |
| 73 | +RUN git clone --tags https://github.com/puppetlabs/puppetlabs-facts ../facts && \ |
| 74 | + $(cd ../facts && git checkout $(git describe --tags $(git rev-list --tags --max-count=1))) |
| 75 | + |
| 76 | +# Check that all dependencies are installed. |
| 77 | +RUN /opt/puppetlabs/puppet/bin/puppet module --modulepath $module_path list --tree |
| 78 | +COPY docker/deploy.pp /tmp/deploy.pp |
| 79 | +RUN ["sh", "-c", "/opt/puppetlabs/puppet/bin/puppet apply --modulepath $module_path /tmp/deploy.pp"] |
| 80 | + |
| 81 | +# Now move the project directory's files into the image. That way, if these |
| 82 | +# files change, caching will skip everything before this. |
| 83 | +COPY docker/bin/helpers/run-upgrade.sh /tmp/bin/run-upgrade.sh |
| 84 | +COPY files/ ./files/ |
| 85 | +COPY locales/ ./locales/ |
| 86 | +COPY spec/ ./spec/ |
| 87 | +COPY task_spec/ ./task_spec/ |
| 88 | +COPY tasks/ ./tasks/ |
| 89 | +COPY templates/ ./templates |
| 90 | +COPY types/ ./types/ |
| 91 | +COPY Gemfile Gemfile.lock Rakefile ./ |
| 92 | +COPY lib/ ./lib/ |
| 93 | +COPY manifests/ ./manifests/ |
| 94 | + |
| 95 | +COPY docker/upgrade.pp /tmp/upgrade.pp |
| 96 | + |
| 97 | +# Print out which versions of the puppet-agent package are available (for reference). |
| 98 | +#RUN yum list puppet-agent --showduplicates |
| 99 | + |
| 100 | +# Perform the upgrade. |
| 101 | +ENTRYPOINT ["/tmp/bin/run-upgrade.sh"] |
0 commit comments