by mg · 4y ago · 0 comments
Say we start with a fresh Debian install, the first line might be
apt update && apt upgrade
The second line might be apt install php
Or Python or Node. And then the commands to create the project directory, switching to it, installing a webserver etc would follow. At some point there would be a line echo "<h1>Hello World</h1>" > index.php
At this point, we accomplished serving a static page.And then line by line, a full web application is created, with routing, templating and user accounts. With no other tool than the command line. So the page would never say "Click on this then click on that..." or "Depending on your environment...". No, you could simply copy every line, paste it to your terminal and thereby create the exact same application.
Ideally the page would have one column of commands for every typical approach like Django, Flask, Laravel, Symfony, NextJS etc.
I would expect this page to start with just one approach - say Django. And then accept pull requests from experts for the other approaches.
So we would have side by side examples of what steps are needed in different environments to create a typical web app nowadays.
I had this idea for a while but so far did not get around doing it. If someone wants to collaborate on it, hit me up.
Then depending on who's writing the tutorial, the content ranges from "create a VM and issue these commands" to gcloud commands to spawn VMs.
Usually, when a student doesn't know anything about React, they won't know anything about Debian, and the whole tutorial will go over their head. Alternatively, it will be highly shallow. Or, usually, both.
A single Docker container can be used like a fast, lightweight VM. And from there on it is just copy+paste.
So on a Linux machine the process would be:
1: docker run -v $(pwd):/var/www --rm -it -p 80:80 debian:11-slim
2: Copy+Paste the lines
3: Enjoy the running web appWhat I'm highlighting is:
* The knowledge depth and time required on your part to maintain the text such that it works on all supported systems
* The fact that you're depending on a number of tools that might become obsolete quite fast, which might throw a wrench into your text.
** For example, Docker stops supporting CLI due to licensing. Linux splinters off to podman, Windows creates its own tool, macOS users will generally continue working with Docker. You'll then be forced to migrate to a different tool, like Vagrant.
Rather than create a text that's a "bring your own developer workstation", create a webpage that I pay $15 for monthly, you record a video explaining a concept, and then you have a button that says "spin up a lab for X". This throws me to a controlled environment, e.g. in AWS, where you tell me the exact steps that will achieve what I want to achieve.
After a few years, the history if it would be very interesting. It would show how much maintenance a minimal web app based on the different approaches needed.
With the shell, all of this can be combined in one command that you can easily read, understand, copy and paste and which is exactly reproducable:
cat << 'EOF' > /etc/apache2/sites-enabled/000-default.conf
WSGIPythonPath /var/www/mysite
<VirtualHost *:80>
WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py
<Directory /var/www/mysite/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
EOF1. Run this:
$EDITOR /etc/apache2/sites-enabled/000-default.conf
2. Now paste in this: [file contents]
Access rights are a separate command in both methods, and if you're really concerned about file encodings (seems unlikely for this sort of thing), that's either an editor setup step at the very start, or one command to convert in either method.Even just reading it would give me an unambiguous insight into the concepts of the framework.
To "fork" it, I would copy all commands into a shellscript and then change something like "mysite" via search+replace. In vim it would be: :%s/mysite/yoursite/gc to change all occurances of "mysite" to "yoursite" and be shown each replacement before it takes place.
echo "<h1>Hello World</h1>" > index.php
in a Dockerfile.