diff --git a/working-with-workspace/code/arguments.txt b/working-with-workspace/code/arguments.txt new file mode 100644 index 0000000..df855ca --- /dev/null +++ b/working-with-workspace/code/arguments.txt @@ -0,0 +1,3 @@ +command('say-hello '): | + #!bash|= + echo ={ @('message') } from ={ input.argument('name') } \ No newline at end of file diff --git a/working-with-workspace/code/attributes.txt b/working-with-workspace/code/attributes.txt new file mode 100644 index 0000000..d5e9d5a --- /dev/null +++ b/working-with-workspace/code/attributes.txt @@ -0,0 +1,5 @@ +attribute('message'): Hello World! + +command('say-hello'): | + #!bash|@ + echo @('message') diff --git a/working-with-workspace/code/confd.txt b/working-with-workspace/code/confd.txt new file mode 100644 index 0000000..3c596d6 --- /dev/null +++ b/working-with-workspace/code/confd.txt @@ -0,0 +1,11 @@ +attributes: + drupal: + docroot: web + +command('apply config'): | + #!php + $ws->confd('workspace:/confd')->apply(); + +confd('workspace:/confd'): + - src: 'vhost.conf' + dst: 'workspace:/.my127ws/docker/nginx/default.conf' diff --git a/working-with-workspace/code/environment-variables.txt b/working-with-workspace/code/environment-variables.txt new file mode 100644 index 0000000..188c4a9 --- /dev/null +++ b/working-with-workspace/code/environment-variables.txt @@ -0,0 +1,7 @@ +command('say-hello '): + env: + MESSAGE: = @('message') + NAME: = input.argument('name') + exec: | + #!bash|= + echo "$MESSAGE from $NAME" diff --git a/working-with-workspace/code/installation.txt b/working-with-workspace/code/installation.txt new file mode 100644 index 0000000..4339944 --- /dev/null +++ b/working-with-workspace/code/installation.txt @@ -0,0 +1,8 @@ +# Download from GitHub. +wget https://github.com/my127/workspace/releases/download/0.1.3/ws + +# Make it executable. +chmod +x ws + +# Make it accessible. +mv ws /usr/local/bin \ No newline at end of file diff --git a/working-with-workspace/code/nginx-vhost.txt b/working-with-workspace/code/nginx-vhost.txt new file mode 100644 index 0000000..a675d82 --- /dev/null +++ b/working-with-workspace/code/nginx-vhost.txt @@ -0,0 +1,8 @@ +server { + server_name _; + root /app/{{ @('drupal.docroot' )}}; + +# output +server { + server_name _; + root /app/web; \ No newline at end of file diff --git a/working-with-workspace/code/run-passthru.txt b/working-with-workspace/code/run-passthru.txt new file mode 100644 index 0000000..fb90143 --- /dev/null +++ b/working-with-workspace/code/run-passthru.txt @@ -0,0 +1,5 @@ +command('say-hello'): + #!bash + run echo 'Hello World' + + passthru echo 'Hello World' diff --git a/working-with-workspace/code/secrets.txt b/working-with-workspace/code/secrets.txt new file mode 100644 index 0000000..96f7659 --- /dev/null +++ b/working-with-workspace/code/secrets.txt @@ -0,0 +1,9 @@ +# ws secret generate-random-key +key('default'): 'd38be3b7aa42fdbfb14c0d25f07bc1875edd5f13f640cd76' + +# ws secret encrypt 'Hello World!' +attribute('message'): = decrypt('YTozOntpOjA7czo3OiJkZWZhdWx0Ijt') + +command('say-hello'): | + #!bash|@ + echo @('message') diff --git a/working-with-workspace/code/simple-command.txt b/working-with-workspace/code/simple-command.txt new file mode 100644 index 0000000..aea7722 --- /dev/null +++ b/working-with-workspace/code/simple-command.txt @@ -0,0 +1,12 @@ +# workspace.yml + +workspace('oliverdavies-uk'): + description: My personal website codebase. + +command('say-hello'): + #!bash + echo 'Hello world' + +command('say-hello'): + #!php + echo 'Hello World'; \ No newline at end of file diff --git a/working-with-workspace/code/workspace-talks.txt b/working-with-workspace/code/workspace-talks.txt new file mode 100644 index 0000000..7329958 --- /dev/null +++ b/working-with-workspace/code/workspace-talks.txt @@ -0,0 +1,34 @@ +attributes: + rst2pdf: + command: | + = 'rst2pdf ' ~ @('rst2pdf.filename.rst') ~ ' + --break-level 1 + --stylesheets main + --fit-background-mode scale + --extension-module preprocess + --output ' ~ @('rst2pdf.filename.pdf') + filename: + pdf: slides.pdf + rst: slides.rst + thumbnail: + filename: thumbnail.png + +command('pdf generate '): | + #!bash|= + cd ={ input.argument('talk') } + passthru ={ @('rst2pdf.command') } + +command('pdf watch '): | + #!bash|= + cd ={ input.argument('talk') } + passthru nodemon -e rst,style,txt -x "={ @('rst2pdf.command') }" + +command('thumbnail '): + env: + PDF_FILENAME: = @('rst2pdf.filename.pdf') + THUMBNAIL_FILENAME: = @('thumbnail.filename') + exec: | + #!bash|= + cd ={ input.argument('talk') } + passthru gs -sDEVICE=png16m -r300 -dDownScaleFactor=4 + -sOutputFile=$THUMBNAIL_FILENAME -dLastPage=1 $PDF_FILENAME diff --git a/working-with-workspace/images/helper-passthru.png b/working-with-workspace/images/helper-passthru.png new file mode 100644 index 0000000..c4fcc38 Binary files /dev/null and b/working-with-workspace/images/helper-passthru.png differ diff --git a/working-with-workspace/images/helper-run.png b/working-with-workspace/images/helper-run.png new file mode 100644 index 0000000..1fffe1a Binary files /dev/null and b/working-with-workspace/images/helper-run.png differ diff --git a/working-with-workspace/images/output-command.png b/working-with-workspace/images/output-command.png new file mode 100644 index 0000000..7ff4ca7 Binary files /dev/null and b/working-with-workspace/images/output-command.png differ diff --git a/working-with-workspace/images/output-simple.png b/working-with-workspace/images/output-simple.png new file mode 100644 index 0000000..3711797 Binary files /dev/null and b/working-with-workspace/images/output-simple.png differ diff --git a/working-with-workspace/main.style b/working-with-workspace/main.style index 0eb1c1a..cb8939b 100644 --- a/working-with-workspace/main.style +++ b/working-with-workspace/main.style @@ -13,6 +13,7 @@ pageSetup: pageTemplates: coverPage: + # background: images/title.png frames: [] [12%, 10%, 76%, 75%] showFooter: false @@ -21,38 +22,47 @@ pageTemplates: titlePage: alignment: TA_CENTER frames: [] - [8%, 8%, 90%, 60%] + [8%, 8%, 85%, 65%] showFooter: true showHeader: false standardPage: frames: [] - [3%, 3%, 94%, 92%] + [3%, 3%, 92%, 92%] showFooter: true showHeader: false + imagePage: + alignment: TA_CENTER + frames: [] + [12%, 10%, 76%, 80%] + showFooter: true + showHeader: false + + outputPage: + frames: [] + [8%, 10%, 82%, 65%] + showFooter: false + showHeader: false + linkColor: #24608a styles: normal: - fontSize: 28 + fontSize: 24 + leading: 32 textColor: #383745 bodytext: alignment: TA_LEFT heading: - alignment: TA_CENTER - fontSize: 24 + fontSize: 20 spaceAfter: 16 textColor: #24608a - heading1: - parent: heading - alignment: TA_LEFT - title: - fontSize: 250% + fontSize: 300% parent: heading bullet-list: @@ -69,13 +79,49 @@ styles: titleslideinfo: alignment: TA_CENTER - fontSize: 120% + fontSize: 140% parent: normal footer: alignment: TA_RIGHT fontName: stdMono - fontSize: 18 + fontSize: 20 textColor: #24608a rightIndent: 16 spaceBefore: 0 + + literal: + backColor: #eeeeee + fontName: stdMono + + code: + backColor: #eeeeee + borderWidth: 0 + fontSize: 20 + leading: 24 + parent: literal + spaceBefore: 4 + + blockquote: + parent: normal + fontName: stdItalic + leading: 36 + + attribution: + parent: normal + textColor: #66666 + + centred: + alignment: TA_CENTER + parent: bodytext + + centredtitle: + alignment: TA_CENTER + fontName: stdBold + fontSize: 48 + leading: 64 + parent: heading + + text-lg: + parent: bodytext + fontSize: 150% \ No newline at end of file diff --git a/working-with-workspace/slides.rst b/working-with-workspace/slides.rst index a6fb622..ddb72a5 100644 --- a/working-with-workspace/slides.rst +++ b/working-with-workspace/slides.rst @@ -11,22 +11,27 @@ Oliver Davies, Inviqa .. raw:: pdf - TextAnnotation "Full stack Developer and Systems Administrator" + TextAnnotation "Full stack Developer and Systems Administrator" + TextAnnotation "Organiser of PHP South Wales" - PageBreak standardPage +.. page:: standardPage What is Workspace? ================== * A tool that we use and maintain at Inviqa +* Primarily for building and managing Docker Compose environments +* Built on Symfony * Create custom commands for your project environments * Alternative to a bash script or a Makefile +* And more... .. raw:: pdf - TextAnnotation "Available on GitHub, MIT licensed." - - TextAnnotation "Useful for simplifying long, complicated commands, e.g. Docker, Ansible." + TextAnnotation "Available on GitHub, MIT licensed." + TextAnnotation "Uses Config, Console, Dependency Injection, Expression Language, Finder and YAML components, as well as Twig." + TextAnnotation "Replacement for commands like 'make build'" + TextAnnotation "Useful for simplifying long, complicated commands, e.g. Docker, Ansible." Features ======== @@ -34,21 +39,172 @@ Features * Commands * Functions * Attributes -* Managing secrets -* Configuration files +* Encrypting/decrypting secrets +* Generating configuration files +* Global services: logging, mail, proxy -.. Change to a title page .. raw:: pdf - PageBreak titlePage + TextAnnotation "Generating settings.php files, Dockerfiles and Docker Compose from a central set of attributes." + TextAnnotation "Logging with kibana, mailhog, Traefik proxy." -Demo -==== +Installation +============ + +.. code-block:: bash + :include: code/installation.txt + +.. page:: imagePage + +.. image:: images/output-simple.png + :width: 15cm + +.. page:: titlePage + +.. class:: centredtitle + +Replacing your Makefile + +.. page:: standardPage + +Running simple commands +======================= + +.. code-block:: yaml + :include: code/simple-command.txt + :linenos: + +.. page:: imagePage + +.. image:: images/output-command.png + :width: 15cm + +.. page:: standardPage + +'run' vs. 'passthru' +==================== + +.. code-block:: yaml + :include: code/run-passthru.txt + +.. image:: images/helper-run.png + :width: 20cm + +.. image:: images/helper-passthru.png + :width: 20cm + +Attributes +========== + +.. code-block:: yaml + :include: code/attributes.txt + :linenos: + +Arguments +========= + +.. code-block:: yaml + :include: code/arguments.txt + :linenos: + +Environment variables +===================== + +.. code-block:: yaml + :include: code/environment-variables.txt + :linenos: + +Managing secrets +================ + +.. code-block:: yaml + :include: code/secrets.txt -.. Change to a standard page .. raw:: pdf - PageBreak standardPage + TextAnnotation "Shortened for slides" + TextAnnotation "Store default key in an overrides file that's ignored from Git, and somewhere secure like a password manager." + +.. page:: titlePage + +.. class:: centredtitle + +Example: building slides from rst2pdf + +.. page:: standardPage + +Attributes +========== + +.. code-block:: yaml + :include: code/workspace-talks.txt + :end-before: command('pdf generate '): | + +Generating PDFs +=============== + +.. code-block:: yaml + :include: code/workspace-talks.txt + :start-at: command('pdf generate '): | + :end-before: command('thumbnail '): + +Generating thumbnails +===================== + +.. code-block:: yaml + :include: code/workspace-talks.txt + :start-at: command('thumbnail '): + +.. page:: titlePage + +.. class:: centredtitle + +Configuration files + +.. page:: standardPage + +Using confd +=========== + +.. code-block:: yaml + :include: code/confd.txt + :linenos: + +.. raw:: pdf + + TextAnnotation ".twig file extension is assumed." + +vhost.conf.twig +=============== + +The source file. + +| + +.. code-block:: twig + :include: code/nginx-vhost.txt + :end-before: # output + :linenos: + +default.conf +============ + +The generated file. + +| + +.. code-block:: nginx + :include: code/nginx-vhost.txt + :start-after: # output + :linenos: + +.. page:: titlePage + +.. class:: centredtitle + +Demo: "Workspacing" my site + +.. page:: standardPage Thanks! ======= @@ -56,7 +212,8 @@ Thanks! References: * https://github.com/my127/workspace -* https://github.com/opdavies/working-with-workspace-demo +* https://oliverdavies.link/workspace-demo +* https://oliverdavies.link/workspacing-site |