Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request regarding .templates (overridden)? #128

Open
simonlock opened this issue Jan 12, 2020 · 4 comments
Open

Feature request regarding .templates (overridden)? #128

simonlock opened this issue Jan 12, 2020 · 4 comments

Comments

@simonlock
Copy link

Hi Graham

Would it be feasible to introduce something like an "override" folder within .templates folder which would be used at a higher priority than the default templates found within the .templates folder when creating docker containers? And to include this folder of overridden templates in the automated backups?

I've made several changes to the defaults found in .templates that you provide i.e. different images, networking and ports and I find myself having to redo my configuration when IoTstack is updated. I think this would be a very useful enhancement and should cause no issues for the current users of IOTstack. Just an idea.

Best regards

Simon

@Slyke
Copy link
Collaborator

Slyke commented Jan 13, 2020

I think maybe a yaml merging type code would be better suited for this type of thing? That way it can inject properties under specific objects, while still providing updates where necessary.

I could probably code something like this, could use Python or NodeJS for it. Python is probably better as it comes installed already in most systems (especially Raspberry Pis).

@simonlock
Copy link
Author

I agree. The merging sound like an excellent idea. That would allow for the overriding of components of each template file, therefore allowing customisation, whilst not having to replace the template files completely.

@Slyke Slyke mentioned this issue Jan 22, 2020
@Slyke
Copy link
Collaborator

Slyke commented Jan 26, 2020

Found some example code that will achieve this: https://stackoverflow.com/questions/47424865/merge-two-yaml-files-in-python

my-custom.yml example:

services:
  pihole:
    restart: always
    extra_hosts:
      - router: 192.168.1.1
      - iotstack 192.168.1.5

The current service.yml for pihole:

pihole:
    container_name: pihole
    image: pihole/pihole:latest
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "8089:80/tcp"
      #- "443:443/tcp"
    env_file:
      - ./services/pihole/pihole.env
    volumes:
       - ./volumes/pihole/etc-pihole/:/etc/pihole/
       - ./volumes/pihole/etc-dnsmasq.d/:/etc/dnsmasq.d/
    dns:
      - 127.0.0.1
      - 1.1.1.1
    # Recommended but not required (DHCP needs NET_ADMIN)
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    cap_add:
      - NET_ADMIN
    restart: unless-stopped

The output to docker-compose.yml:

  pihole:
    extra_hosts:
      - router: 192.168.1.1
      - iotstack 192.168.1.5
    container_name: pihole
    image: pihole/pihole:latest
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "8089:80/tcp"
      #- "443:443/tcp"
    env_file:
      - ./services/pihole/pihole.env
    volumes:
       - ./volumes/pihole/etc-pihole/:/etc/pihole/
       - ./volumes/pihole/etc-dnsmasq.d/:/etc/dnsmasq.d/
    dns:
      - 127.0.0.1
      - 1.1.1.1
    # Recommended but not required (DHCP needs NET_ADMIN)
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    cap_add:
      - NET_ADMIN
    restart: always

You can see that restart is overridden by the value in my-custom.yml and that extra_hosts with it's properties is added in.

@simonlock
Copy link
Author

Excellent. This sounds like the perfect solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants