From 0a0a38d9dba3750bff47c2bbf67b2056d5ce039c Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Sun, 22 Dec 2019 19:59:57 +0100 Subject: [PATCH] examples --- examples/context/foo/bar/hi.py | 3 +++ examples/context/foo/bar/simple.j2 | 5 ++++ examples/context/spec.yml | 10 ++++++++ examples/custom_tag/simple.j2 | 3 +++ examples/custom_tag/spec.yml | 14 +++++++++++ examples/full/build/Dockerfile.j2 | 13 ++++++++++ examples/full/build/new.py | 3 +++ examples/full/build/old.py | 3 +++ examples/full/registry/docker-compose.yml | 14 +++++++++++ examples/full/registry/htpasswd | 2 ++ examples/full/spec.yml | 25 +++++++++++++++++++ examples/multiple_templates/recipes/alpine.j2 | 3 +++ examples/multiple_templates/recipes/debian.j2 | 3 +++ examples/multiple_templates/spec.yml | 13 ++++++++++ .../registry/docker-compose.yml | 14 +++++++++++ examples/push_to_registry/registry/htpasswd | 2 ++ examples/push_to_registry/simple.j2 | 3 +++ examples/push_to_registry/spec.yml | 20 +++++++++++++++ examples/simple/simple.j2 | 3 +++ examples/simple/spec.yml | 13 ++++++++++ 20 files changed, 169 insertions(+) create mode 100644 examples/context/foo/bar/hi.py create mode 100644 examples/context/foo/bar/simple.j2 create mode 100644 examples/context/spec.yml create mode 100644 examples/custom_tag/simple.j2 create mode 100644 examples/custom_tag/spec.yml create mode 100644 examples/full/build/Dockerfile.j2 create mode 100644 examples/full/build/new.py create mode 100644 examples/full/build/old.py create mode 100644 examples/full/registry/docker-compose.yml create mode 100644 examples/full/registry/htpasswd create mode 100644 examples/full/spec.yml create mode 100644 examples/multiple_templates/recipes/alpine.j2 create mode 100644 examples/multiple_templates/recipes/debian.j2 create mode 100644 examples/multiple_templates/spec.yml create mode 100644 examples/push_to_registry/registry/docker-compose.yml create mode 100644 examples/push_to_registry/registry/htpasswd create mode 100644 examples/push_to_registry/simple.j2 create mode 100644 examples/push_to_registry/spec.yml create mode 100644 examples/simple/simple.j2 create mode 100644 examples/simple/spec.yml diff --git a/examples/context/foo/bar/hi.py b/examples/context/foo/bar/hi.py new file mode 100644 index 0000000..0f38f51 --- /dev/null +++ b/examples/context/foo/bar/hi.py @@ -0,0 +1,3 @@ +import sys + +print(f'Hi, I am {sys.version}') diff --git a/examples/context/foo/bar/simple.j2 b/examples/context/foo/bar/simple.j2 new file mode 100644 index 0000000..a0ee796 --- /dev/null +++ b/examples/context/foo/bar/simple.j2 @@ -0,0 +1,5 @@ +FROM python:{{ version }}-alpine + +COPY ./hi.py . + +CMD [ "python", "hi.py" ] \ No newline at end of file diff --git a/examples/context/spec.yml b/examples/context/spec.yml new file mode 100644 index 0000000..f071322 --- /dev/null +++ b/examples/context/spec.yml @@ -0,0 +1,10 @@ +variables: + version: + - 3.8 + - 3.7 + +recipe: ./simple.j2 +context: ./foo/bar + +run: yes +parallel: no \ No newline at end of file diff --git a/examples/custom_tag/simple.j2 b/examples/custom_tag/simple.j2 new file mode 100644 index 0000000..7b9ef89 --- /dev/null +++ b/examples/custom_tag/simple.j2 @@ -0,0 +1,3 @@ +FROM alpine:{{ version}} + +CMD [ "echo", "Hi {{ name }} from {{ version }}" ] \ No newline at end of file diff --git a/examples/custom_tag/spec.yml b/examples/custom_tag/spec.yml new file mode 100644 index 0000000..d6a30c3 --- /dev/null +++ b/examples/custom_tag/spec.yml @@ -0,0 +1,14 @@ +variables: + version: + - 3.11 + - 3.10 + - 3.9 + name: + - Alice + - Bob + +recipe: ./simple.j2 +tag: 'my_image:{{version}}-{{name}}' + +run: yes +parallel: no \ No newline at end of file diff --git a/examples/full/build/Dockerfile.j2 b/examples/full/build/Dockerfile.j2 new file mode 100644 index 0000000..1243332 --- /dev/null +++ b/examples/full/build/Dockerfile.j2 @@ -0,0 +1,13 @@ +FROM python:{{ python_version }}-{{base_image}} + +RUN pip install termcolor=={{ package_version }} + +WORKDIR /app + +{% if package_version == '1.1.0' %} +COPY ./new.py main.py +{% else %} +COPY ./old.py main.py +{% endif %} + +CMD [ "python", "main.py" ] \ No newline at end of file diff --git a/examples/full/build/new.py b/examples/full/build/new.py new file mode 100644 index 0000000..a227904 --- /dev/null +++ b/examples/full/build/new.py @@ -0,0 +1,3 @@ +from termcolor import cprint + +cprint('Hello 👋', 'blue', attrs=['bold']) diff --git a/examples/full/build/old.py b/examples/full/build/old.py new file mode 100644 index 0000000..c64ac2a --- /dev/null +++ b/examples/full/build/old.py @@ -0,0 +1,3 @@ +from termcolor import colored + +print(colored('Hello 👋', 'blue', attrs=['bold'])) diff --git a/examples/full/registry/docker-compose.yml b/examples/full/registry/docker-compose.yml new file mode 100644 index 0000000..1b270cd --- /dev/null +++ b/examples/full/registry/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3.7' + +services: + registry: + image: registry + container_name: registry + ports: + - 5000:5000 + volumes: + - ./htpasswd:/auth/htpasswd + environment: + - REGISTRY_AUTH=htpasswd + - REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm + - REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd diff --git a/examples/full/registry/htpasswd b/examples/full/registry/htpasswd new file mode 100644 index 0000000..b64b692 --- /dev/null +++ b/examples/full/registry/htpasswd @@ -0,0 +1,2 @@ +foo:$2y$05$dxXE5QaBKd5eV0gLBxFJtOJpAHKEusdZfPC2Ucssyg3s/2YjoRIXW + diff --git a/examples/full/spec.yml b/examples/full/spec.yml new file mode 100644 index 0000000..c26028e --- /dev/null +++ b/examples/full/spec.yml @@ -0,0 +1,25 @@ +variables: + python_version: + - 3.8 + - 3.7 + - 3.6 + - 3.5 + base_image: + - alpine + - slim + package_version: + - 1.1.0 + - 1.0.1 + - 1.0.0 + +context: ./build +recipe: './Dockerfile.j2' +tag: "{{package_version}}:{{base_image}}-{{python_version}}" + +parallel: no +push: yes +run: yes +registry: + username: foo + password: bar + host: localhost:5000 \ No newline at end of file diff --git a/examples/multiple_templates/recipes/alpine.j2 b/examples/multiple_templates/recipes/alpine.j2 new file mode 100644 index 0000000..653f4cc --- /dev/null +++ b/examples/multiple_templates/recipes/alpine.j2 @@ -0,0 +1,3 @@ +FROM alpine + +CMD [ "echo", "Hi {{ name }} from {{ os }}" ] \ No newline at end of file diff --git a/examples/multiple_templates/recipes/debian.j2 b/examples/multiple_templates/recipes/debian.j2 new file mode 100644 index 0000000..be7f89c --- /dev/null +++ b/examples/multiple_templates/recipes/debian.j2 @@ -0,0 +1,3 @@ +FROM debian + +CMD [ "echo", "Hi {{ name }} from {{ os }}" ] \ No newline at end of file diff --git a/examples/multiple_templates/spec.yml b/examples/multiple_templates/spec.yml new file mode 100644 index 0000000..57f2b69 --- /dev/null +++ b/examples/multiple_templates/spec.yml @@ -0,0 +1,13 @@ +variables: + os: + - alpine + - debian + name: + - Alice + - Bob + +recipe: './recipes/{{ os }}.j2' +tag: 'hello:{{os}}-{{name}}' + +run: yes +parallel: no \ No newline at end of file diff --git a/examples/push_to_registry/registry/docker-compose.yml b/examples/push_to_registry/registry/docker-compose.yml new file mode 100644 index 0000000..1b270cd --- /dev/null +++ b/examples/push_to_registry/registry/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3.7' + +services: + registry: + image: registry + container_name: registry + ports: + - 5000:5000 + volumes: + - ./htpasswd:/auth/htpasswd + environment: + - REGISTRY_AUTH=htpasswd + - REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm + - REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd diff --git a/examples/push_to_registry/registry/htpasswd b/examples/push_to_registry/registry/htpasswd new file mode 100644 index 0000000..b64b692 --- /dev/null +++ b/examples/push_to_registry/registry/htpasswd @@ -0,0 +1,2 @@ +foo:$2y$05$dxXE5QaBKd5eV0gLBxFJtOJpAHKEusdZfPC2Ucssyg3s/2YjoRIXW + diff --git a/examples/push_to_registry/simple.j2 b/examples/push_to_registry/simple.j2 new file mode 100644 index 0000000..7b9ef89 --- /dev/null +++ b/examples/push_to_registry/simple.j2 @@ -0,0 +1,3 @@ +FROM alpine:{{ version}} + +CMD [ "echo", "Hi {{ name }} from {{ version }}" ] \ No newline at end of file diff --git a/examples/push_to_registry/spec.yml b/examples/push_to_registry/spec.yml new file mode 100644 index 0000000..4b3f883 --- /dev/null +++ b/examples/push_to_registry/spec.yml @@ -0,0 +1,20 @@ +# Run docker-compose up before starting tumbo + +variables: + version: + - 3.11 + - 3.10 + - 3.9 + name: + - Alice + - Bob + +recipe: ./simple.j2 + +push: yes +run: yes +parallel: no +registry: + username: foo + password: bar + host: localhost:5000 \ No newline at end of file diff --git a/examples/simple/simple.j2 b/examples/simple/simple.j2 new file mode 100644 index 0000000..f2fb21f --- /dev/null +++ b/examples/simple/simple.j2 @@ -0,0 +1,3 @@ +FROM alpine:{{ version }} + +CMD [ "echo", "Hi {{ name }} from {{ version }}" ] \ No newline at end of file diff --git a/examples/simple/spec.yml b/examples/simple/spec.yml new file mode 100644 index 0000000..233e9af --- /dev/null +++ b/examples/simple/spec.yml @@ -0,0 +1,13 @@ +variables: + version: + - 3.11 + - 3.10 + - 3.9 + name: + - Alice + - Bob + +recipe: ./simple.j2 + +run: yes +parallel: no \ No newline at end of file