-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from rwaffen/docker
Docker
- Loading branch information
Showing
9 changed files
with
214 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Publish Docker image | ||
|
||
on: | ||
# push: | ||
# branches: | ||
# - develop | ||
workflow_dispatch: | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc | ||
with: | ||
context: . | ||
push: false | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,3 +56,6 @@ package-lock.json | |
|
||
# Git repo clones | ||
/repos | ||
|
||
# Vagrant | ||
/.vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# Build the container | ||
|
||
There is a Dockerfile to build a container. This can be done with: | ||
|
||
cd hdm | ||
docker build -t hdm . | ||
|
||
# hdm_env for docker | ||
|
||
to have all the hdm external parts together we recommend to put this into a folder called `hdm_env`. | ||
The structure might look like this: | ||
|
||
hdm_env/ | ||
├── certs | ||
│ ├── puppetdb.ca.pem | ||
│ ├── puppetdb.cert.pem | ||
│ └── puppetdb.key.pem | ||
├── database.yml | ||
├── db | ||
│ ├── development.sqlite3 | ||
│ └── test.sqlite3 | ||
├── hdm.yml | ||
├── hiera | ||
│ └── hiera files ... | ||
└── hiera.yaml | ||
|
||
If you are running this directly on the puppet compiler the hiera directory might not be needed. But if you have hiera as a seperate repository this might be helpfull. You also can mount it directly in the compose file. | ||
|
||
## hdm config example | ||
|
||
development: | ||
read_only: true | ||
allow_encryption: false | ||
puppet_db: | ||
server: "https://puppetdb.example.com:8081" | ||
pem: | ||
key: "/hdm_env/certs/puppet.key.pem" | ||
cert: "/hdm_env/certs/puppet.cert.pem" | ||
ca_file: "/hdm_env/certs/puppet.ca.pem" | ||
config_dir: "/etc/puppetlabs/code" | ||
|
||
# if not set, the default value 'hiera.yaml' of your environment is used | ||
hiera_config_file: "/hdm_env/hiera.yaml" | ||
|
||
|
||
## hdm database config example | ||
|
||
default: &default | ||
adapter: sqlite3 | ||
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> | ||
timeout: 5000 | ||
|
||
development: | ||
<<: *default | ||
database: /hdm_env/db/development.sqlite3 | ||
|
||
test: | ||
<<: *default | ||
database: /hdm_env/db/test.sqlite3 | ||
|
||
production: | ||
<<: *default | ||
database: /hdm_env/db/production.sqlite3 | ||
|
||
## hdm hiera config example (Optional) | ||
|
||
This file can be used as default file for all ore only one environment. You dont need this if you have this already in your environment. | ||
|
||
--- | ||
version: 5 | ||
defaults: | ||
datadir: 'data' | ||
data_hash: 'yaml_data' | ||
|
||
hierarchy: | ||
- name: "Hiera general Yaml" | ||
paths: | ||
- "os/%{::os.name}-%{::os.release.full}.yaml" | ||
- "os/%{::os.name}-%{::os.release.major}.yaml" | ||
- "os/%{::os.name}.yaml" | ||
- "os/%{::os.family}-%{::os.release.major}.yaml" | ||
- "os/%{::os.family}.yaml" | ||
|
||
- name: "Puppet Environments" | ||
path: "env/%{::environment}.yaml" | ||
|
||
- name: "Common Yaml" | ||
path: "common.yaml" | ||
|
||
# Docker Compose | ||
|
||
For docker compose see `docker-compose.yaml` or use this example: | ||
|
||
--- | ||
version: "3.5" | ||
services: | ||
hdm: | ||
image: betadots/hdm | ||
container_name: hdm | ||
environment: | ||
- TZ=Europe/Berlin | ||
volumes: | ||
# folder to save the rails sqlite | ||
- /hdm_env/db:/hdm_env/db | ||
# certs to talk to puppetdb | ||
- /hdm_env/certs:/hdm_env/certs:ro | ||
# hdm main config | ||
- { type: 'bind', source: '/hdm_env/hdm.yml', target: '/hdm/config/hdm.yml', read_only: true } | ||
# hdm database config | ||
- { type: 'bind', source: '/hdm_env/database.yml', target: '/hdm/config/database.yml', read_only: true } | ||
|
||
##### mount hiera as data dir | ||
- /hdm_env/hiera:/etc/puppetlabs/code/environments/pre_development/data:ro | ||
- /hdm_env/hiera:/etc/puppetlabs/code/environments/development/data:ro | ||
- /hdm_env/hiera:/etc/puppetlabs/code/environments/test/data:ro | ||
- /hdm_env/hiera:/etc/puppetlabs/code/environments/production/data:ro | ||
|
||
ports: | ||
- 3000:3000 | ||
restart: unless-stopped |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
# All Vagrant configuration is done below. The "2" in Vagrant.configure | ||
# configures the configuration version (we support older styles for | ||
# backwards compatibility). Please don't change it unless you know what | ||
# you're doing. | ||
Vagrant.configure("2") do |config| | ||
config.vm.box = "betadots/centos8p6" | ||
config.vm.network "forwarded_port", guest: 3000, host: 3000, host_ip: "127.0.0.1" | ||
|
||
config.vm.synced_folder "../hdm_env", "/hdm_env" | ||
config.vm.synced_folder ".", "/hdm" | ||
|
||
config.vm.provider "virtualbox" do |vb| | ||
vb.memory = "4096" | ||
end | ||
|
||
config.vm.provision "shell", inline: <<-SHELL | ||
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo | ||
sudo yum install -y docker-ce docker-ce-cli docker-compose-plugin containerd.io | ||
sudo systemctl enable --now docker.service | ||
SHELL | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters