Teach deploystatic docker container to also act as a server
authorMagnus Hagander <magnus@hagander.net>
Sun, 14 Sep 2025 12:11:14 +0000 (14:11 +0200)
committerMagnus Hagander <magnus@hagander.net>
Sun, 14 Sep 2025 12:11:14 +0000 (14:11 +0200)
If wanted, for those that don't have access to a local webserver (!),
this is an easy way to preview a static site.

tools/deploystatic/Dockerfile
tools/deploystatic/README.docker

index b732b98e6ee4993e47ec9ebe984203ab0f575394..855e7f38b7ecf32da4f52d0d0df797016cfad08e 100644 (file)
@@ -1,6 +1,6 @@
 FROM debian:bullseye
 RUN apt-get -y update && apt-get -y upgrade && apt-get -y install python3-jinja2 python3-markdown python3-dateutil && apt-get -y clean
 RUN mkdir /source /target
-ADD deploystatic.py /
-ENTRYPOINT ["/deploystatic.py"]
-CMD ["/source", "/target"]
\ No newline at end of file
+ADD deploystatic.py entrypoint.sh /
+EXPOSE 9099
+ENTRYPOINT ["/entrypoint.sh"]
index 3f81d06735f27711ba7a0e53777e41b284e4d73d..ed6ecc234877504abda583da08f5558c08e6afaf 100644 (file)
@@ -5,11 +5,20 @@ example:
 docker build -t deploystatic .
 
 
-And then to use it:
+To use this container to deploy to a static directory, use:
 
 docker run -it --rm -v `pwd`:/source -v /tmp/statictest:/target deploystatic
 
 (In this case taking the templates in the current directory and deploying the
 result to /tmp/statictest - adjust for your own directories)
 
-You can also just specify the default parameters as docker arguments.
\ No newline at end of file
+You can also just specify the default parameters as docker arguments.
+
+
+You can also use the docker container to run a simple static webserver with
+the output of the static directory like this:
+
+docker run -it --rm -v `pwd`:/source -p 9099:9099 deploystatic -serve
+
+This will deploy the current directory inside the container and start a webserver
+on port 9099.
\ No newline at end of file