Need a guide on how to set up Silverblue for a Web Development environment


#1

OK, I have been looking at this so that I can move my web development from Windows to Linux.

I am not using Silverblue (yet!) but I want to figure out a workflow that will also work on SilverBlue and is something that I can develop further when needed.

I want something that:

  1. Does not require any modification of the overlay (local install )
  2. Can allow easy modification
  3. Local development domain resolution

My current thinking:

Use Podman for a container for php/httpd and another one for Mariadb. this prevents the requirement for adding packages to the overlay.

Following https://developers.redhat.com/blog/2018/11/29/managing-containerized-system-services-with-podman/ I can get a single site running, but I have gotten stuck in a few places.

For a proper web development workflow it needs to be extended/modified to work with the following data structure:

dev/mysql-data
dev/www/domains/web
dev/vhosts

The first one is obvious and the same as in that blog. The second one is similar - but when using composer in projects generally the new files will be in a subdirectory (web in this case).

The third folder is to allow custom vhosts declarations. The one I have now is pretty simple and contains the following:

<VirtualHost *:80>
UseCanonicalName Off
VirtualDocumentRoot /var/www/%1/web
ErrorLog /var/www/error.log
CustomLog /var/www/requests.log combined

This works on a locally installed httpd server (it allows for multiple sited suffixed by “.localhost” to work), but not for the container, because I probably have an incorrect entry point.

The service files suggested in the blog keep the webserver container active. For development ideally they would be woken up once accessed and once the command is run, shut down. This will then also allow updating of the vhosts files to have an instantaneous impact.

Finally a snippet would be required for the host system to be resolved by systemd-resolved to redirect domains other than .localhost to be redirected to localhost. This seems to be possible by adding a configuration file at /etc/systemd/resolved.conf.d/*.conf but I haven’t figured out what it should contain. With this and the vhosts configuration it should be possible to have a semi automated web development environment.

Any pointers to setting this up/providing a step by step guide would be appreciated (and I think it would also make a great guide for the website).


#2

Hmm so some random notes:

  • Depending on what exactly you’re doing, toolbox may be useful.
  • IME nginx is a tad easier for workflows like this than Apache.

You probably want to either edit /etc/hosts instead or use podman’s --add-host argument.

I’m actually working on a side project that might help with this, basically a lightweight orchestration system built on podman. Meanwhile, I have some systemd services and scripts I use to manage containers on my server…

Depending on how overkill you want there’s also always minikube / minishift.