Skip to content

Commit 71b4edc

Browse files
committed
Consolidate dockerfiles and add docs for development
This will reduce the number of files that need to be managed and dependencies that need updated at the same time.
1 parent 3a771df commit 71b4edc

35 files changed

+386
-627
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,13 @@
11
version: 2
22
updates:
3-
# /docker/dev folder
43
- package-ecosystem: docker
5-
directory: "/docker/dev/"
4+
directory: "/docker/"
65
schedule:
7-
interval: daily
8-
time: "13:00"
6+
interval: weekly
97
open-pull-requests-limit: 10
10-
# /docker/prod-all-providers folder
8+
119
- package-ecosystem: bundler
12-
directory: "/docker/prod-all-providers/"
10+
directory: "/docker/"
1311
schedule:
14-
interval: daily
15-
time: "13:00"
16-
open-pull-requests-limit: 10
17-
- package-ecosystem: docker
18-
directory: "/docker/prod-all-providers/"
19-
schedule:
20-
interval: daily
21-
time: "13:00"
22-
open-pull-requests-limit: 10
23-
# /docker/test-all-providers folder
24-
- package-ecosystem: bundler
25-
directory: "/docker/test-all-providers/"
26-
schedule:
27-
interval: daily
28-
time: "13:00"
29-
open-pull-requests-limit: 10
30-
- package-ecosystem: docker
31-
directory: "/docker/test-all-providers/"
32-
schedule:
33-
interval: daily
34-
time: "13:00"
12+
interval: weekly
3513
open-pull-requests-limit: 10

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
.vagrant/
44
.idea/
55
helm-charts/vmpooler/charts/
6+
/docker/data/redis/**
7+
!docker/data/**/*.yaml
8+
!docker/data/**/.gitkeep

README.md

Lines changed: 91 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
# vmpooler-deployment
22

3+
- [vmpooler-deployment](#vmpooler-deployment)
4+
- [VMPooler Components](#vmpooler-components)
5+
- [Docker Registry](#docker-registry)
6+
- [Helm Repository](#helm-repository)
7+
- [Adding / updating charts](#adding--updating-charts)
8+
- [Development](#development)
9+
- [Docker Compose URLs](#docker-compose-urls)
10+
- [Deploy Chart for Testing](#deploy-chart-for-testing)
11+
- [Releasing](#releasing)
12+
- [Contributing](#contributing)
13+
- [License](#license)
14+
315
This repo contains Dockerfiles and a Helm chart that can be used to deploy [VMPooler](https://github.com/puppetlabs/vmpooler). The Release Engineering team at Puppet uses the code here as part of operating our VMPooler instances.
416

17+
## VMPooler Components
18+
19+
The docker image gnerated and hosted by this project contain the following VMPooler components:
20+
21+
- [VMPooler Core](https://github.com/puppetlabs/vmpooler)
22+
- [VMPooler EC2 Provider](https://github.com/puppetlabs/vmpooler-provider-ec2)
23+
- [VMPooler GCE Provider](https://github.com/puppetlabs/vmpooler-provider-gce)
24+
- [VMPooler vSphere Provider](https://github.com/puppetlabs/vmpooler-provider-vsphere)
25+
526
## Docker Registry
627

728
The GitHub Actions in this repository publish images to GitHub Packages. You can browse the VMPooler containers [here](https://github.com/puppetlabs/vmpooler-deployment/pkgs/container/vmpooler-deployment%2Fvmpooler).
829

9-
Containers are organized using image tags:
30+
The vmpooler officially released docker image tags use a semantic version, where the version increments correlate to the increments in any of the gems at `docker/Gemfile`.
1031

11-
- `x.y.z-prod-all-providers` represents images built using the Dockerfile in `docker/prod-all-providers`. These images use the Gemfile in the same directory to pull in current versions of the `vmpooler` gem and the gems for all known production-grade providers.
32+
Image tags starting with `pr<PULL REQUEST NUMBER>-<GIT SHA>` are generated when opening and pushing to a pull request and will periodically be cleaned up.
1233

1334
## Helm Repository
1435

@@ -21,14 +42,74 @@ $ helm repo add vmpooler-deployment https://puppetlabs.github.io/vmpooler-deploy
2142

2243
### Adding / updating charts
2344

24-
```bash
25-
cd docs/
26-
helm package ../helm-charts/*
27-
helm repo index --url https://puppetlabs.github.io/vmpooler-deployment/ .
28-
git add .
29-
cd ..
30-
git commit -a
31-
```
45+
Make the desired changes to the helm chart in helm-charts/vmpooler and run `./update-chart`.
46+
47+
## Development
48+
49+
Prerequisites:
50+
51+
- [Docker](https://docs.docker.com/engine/install/)
52+
- [Docker Compose](https://docs.docker.com/compose/install/)
53+
54+
1. Become familiar with the configuration file `docker/vmpooler.yaml` as described in [VMPooler](https://github.com/puppetlabs/vmpooler) Core.
55+
- The default configuration file only enables the dummy provider built into [VMPooler](https://github.com/puppetlabs/vmpooler) Core. See each project below for documentation on how to use provider specific options:
56+
- [vmpooler-provider-ec2](https://github.com/puppetlabs/vmpooler-provider-ec2)
57+
- [vmpooler-provider-gce](https://github.com/puppetlabs/vmpooler-provider-gce)
58+
- [vmpooler-provider-vsphere](https://github.com/puppetlabs/vmpooler-provider-vsphere)
59+
2. Chose a Development method:
60+
- Develop via local source:
61+
1. Clone all of the known vmpooler projects listed at [vmpooler-components](#vmpooler-components) under a common directory, for example:
62+
63+
```bash
64+
|-- vmpooler-projects
65+
| |--vmpooler-deployment
66+
| |--vmpooler-provider-ec2
67+
| |--vmpooler-provider-gce
68+
| |--vmpooler-provider-vsphere
69+
```
70+
71+
2. From the `vmpooler-projects` directory run `docker build -t vmpooler-local -f vmpooler-deployment/docker/Dockerfile.local .`
72+
3. Run `docker compose -f vmpooler-deployment/docker/docker-compose.local.yml up`
73+
74+
- Develop via Git source:
75+
1. For the component(s) you are developing on, commit and push changes to a branch.
76+
2. Change to the `docker` directory and modify the `Gemfile` as needed to pull the gem(s) from your git branch.
77+
3. Run `./update-gemfile-lock` to update the `Gemfile.lock`
78+
4. Run `docker compose build && docker compose up`.
79+
80+
When a dependency Helm chart is updated, be sure to run `./update-chart-lock` to update the lockfile, otherwise the test and release workflows will fail.
81+
82+
### Docker Compose URLs
83+
84+
These are the default ports used in the docker compose file, to change them edit the `ports` key under the desired service in either `docker/docker-compose.yml` or `docker/docker-compose.local.yml`.
85+
86+
| App/Endpoint | Path |
87+
|--------------------|-------------------------------------------------------------|
88+
| Redis Server | `localhost:6379` (Password: `vmpooler`) |
89+
| Redis Commander | <http://localhost:8080> (Credentials: `admin:admin`) |
90+
| Jaeger | <http://localhost:8081>
91+
| VMPooler API | <http://localhost:8082/api/v2> |
92+
| VMPooler Dashboard | <http://localhost:8082/dashboard> |
93+
| Metrics (API) | <http://localhost:8082/prometheus> |
94+
| Metrics (Manager) | <http://localhost:8083/prometheus> |
95+
96+
### Deploy Chart for Testing
97+
98+
Helm charts are hosted with GitHub Pages since GitHub Packages does not support Helm, so you will need to build the chart locally and push the chart to your own helm repository. Follow these steps to generate a chart to host internally:
99+
100+
1. Update the "appVersion" key in `helm-charts/vmpooler/Chart.yaml` to the docker image tag that was generated by opening a pull request.
101+
2. Update the "version" key to a pre-release tag, something like "x.y.z-rc.1", then run `./build-chart` to build the chart locally, and upload it to your desired location.
102+
103+
## Releasing
104+
105+
Create a GitHub tag and release, publish a new docker image, and helm chart by opening a release prep pull request and running the release action:
106+
107+
1. Bump the "appVersion" key in `helm-charts/vmpooler/Chart.yaml` appropriately based on changes to `docker/Gemfile` abd `docker/Gemfile.lock` in merged pull requests since the last release.
108+
2. Bump the "version" key in `helm-charts/vmpooler/Chart.yaml` appropriately based on changes to the chart itself and increments of the "appVersion" in merged pull requests since the last release.
109+
3. Run `./update-changelog` to update `CHANGELOG.md`.
110+
4. Commit and push changes to a new branch, then open a pull request against `main` and be sure to add the "maintenance" label.
111+
5. After the pull request is approved and merged, then navigate to Actions --> Docker and Helm Release --> run workflow --> Branch: main --> Run workflow.
112+
- This action will push a tagged docker image to the GitHub container registry and helm chart to GitHub pages.
32113

33114
## Contributing
34115

build-chart.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
docker run --rm -it -v $(pwd):/apps --entrypoint /bin/sh alpine/helm \
4+
-c 'helm repo add bitnami https://charts.bitnami.com/bitnami && cd /apps/helm-charts/vmpooler && helm dependency update && cd /apps/docs && helm package ../helm-charts/* && helm repo index --url https://puppetlabs.github.io/vmpooler-deployment/ .'

docker/.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Exclude everything by default; explicitly include necessary files
2+
*
3+
!Gemfile
4+
!Gemfile.lock
5+
!Gemfile.local
6+
!docker-entrypoint.sh

docker/prod-all-providers/Dockerfile renamed to docker/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# RUN:
99
# docker run -e VMPOOLER_CONFIG -p 80:4567 -it vmpooler
1010

11-
FROM jruby:9.3.6-jdk
11+
FROM amd64/jruby:9.3.6-jdk
1212

1313
LABEL org.opencontainers.image.description "VMPooler plus all known providers"
1414

@@ -23,8 +23,7 @@ RUN apt-get update -qq && \
2323
apt-get autoremove -y && \
2424
rm -rf /var/lib/apt/lists/*
2525

26-
RUN gem install bundler && \
27-
gem update --system 3.2.3
26+
RUN gem install bundler
2827

2928
COPY ./docker-entrypoint.sh /usr/local/bin/
3029

docker/Dockerfile.local

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# For local development of vmpooler core and provider gems instead of using a
2+
# git source ensure the following directory structure:
3+
# |-- vmpooler-projects
4+
# | |--vmpooler-deployment
5+
# | |--vmpooler-provider-ec2
6+
# | |--vmpooler-provider-gce
7+
# | |--vmpooler-provider-vsphere
8+
#
9+
# Then change directory into vmpooler-projects and build with:
10+
11+
12+
FROM amd64/jruby:9.3.6-jdk
13+
14+
LABEL org.opencontainers.image.description "VMPooler plus all known providers"
15+
16+
ENV DEBIAN_FRONTEND=noninteractive
17+
ENV LOGFILE=/dev/stdout
18+
ENV RACK_ENV=production
19+
20+
RUN apt-get update -qq && \
21+
apt-get upgrade -y && \
22+
apt-get install -y --no-install-recommends make git netbase && \
23+
apt-get clean autoclean && \
24+
apt-get autoremove -y && \
25+
rm -rf /var/lib/apt/lists/*
26+
27+
COPY vmpooler /opt/vmpooler
28+
COPY vmpooler-provider-ec2 /opt/vmpooler-provider-ec2
29+
COPY vmpooler-provider-gce /opt/vmpooler-provider-gce
30+
COPY vmpooler-provider-vsphere /opt/vmpooler-provider-vsphere
31+
32+
RUN gem install bundler
33+
34+
COPY vmpooler-deployment/docker/docker-entrypoint.sh /usr/local/bin/
35+
36+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
37+
38+
COPY vmpooler-deployment/docker/Gemfile.local ./Gemfile
39+
40+
RUN bundle config set --local jobs 3 && \
41+
bundle install
42+
43+
ENTRYPOINT ["docker-entrypoint.sh"]

docker/Gemfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
2+
3+
gem 'vmpooler', '~> 2.4'
4+
gem 'vmpooler-provider-ec2', '~> 0.0.1'
5+
gem 'vmpooler-provider-gce', '~> 0.4'
6+
gem 'vmpooler-provider-vsphere', '~> 1.6'
7+
8+
# For development install via a git branch use something like:
9+
# gem 'vmpooler', git: 'https://github.com/puppetlabs/vmpooler.git', branch: 'my-feature'
10+
# gem 'vmpooler-provider-ec2', git: 'https://github.com/puppetlabs/vmpooler-provider-ec2.git', branch: 'my-feature'
11+
# gem 'vmpooler-provider-gce', git: 'https://github.com/puppetlabs/vmpooler-provider-gce.git', branch: 'my-feature'
12+
# gem 'vmpooler-provider-vsphere', git: 'https://github.com/puppetlabs/vmpooler-provider-vsphere.git', branch: 'my-feature'

docker/Gemfile.local

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
2+
3+
gem 'vmpooler', path: '/opt/vmpooler'
4+
gem 'vmpooler-provider-ec2', path: '/opt/vmpooler-provider-ec2'
5+
gem 'vmpooler-provider-gce', path: '/opt/vmpooler-provider-gce'
6+
gem 'vmpooler-provider-vsphere', path: '/opt/vmpooler-provider-vsphere'
File renamed without changes.

0 commit comments

Comments
 (0)