Port and node.js server vrsion

I am using tw 5.3.1 on node.js server via podman in rootless mode.

I have seral instance running, each with their own port. Each port needs two occurence in the Dockerfile: one for the export command and one for the command line launching tiddlywiki (the port=808x" argument).

I would like to use an ENV variable in the dockerfile to just have it written once and have zero risk of having two diffrent port numbers.

The following Dockerfile does not have the intended result. It lauches tw on port 8080 (the default) instead of 8088. However, if I write 8088instead of $PORT it effectively open tw on port 8088.

What is wrong? As far as I can say, my use of ENV var is correct.

# Dockerfile pour lancer le tiddlywiki gendat
# copiée et adaptée du modèle elasticdog/tiddlywiki disponible sur le docker hub
from node:20.6.0-alpine3.18

LABEL author="Jean-Pierre RIVIÈRE"
LABEL content="instance de nodejs avec le tiddliwki gendat"

env WORKDIR=/usr/share/tiddlywiki/gendat
env PORT=8088



run apk update && apk add --no-cache tini
run npm install -g tiddlywiki@$TIDDLYWIKI_VERSION && npm install clean --force

ENTRYPOINT ["/sbin/tini", "--"]
CMD ["tiddlywiki", "gendat", "--listen", "host=", "port=$PORT"]

After further investigation, I found out that you can’t have ENV variable subsitution in the CMD command arguments (neither with docker nor with podman).

You have to write your host and ports hard-coded. You could generate your dockerfile en a Makefile though. That way you could achieve what you want.

Here is how I do this with podman on linux. First is the Makefile then the Dockerfile.model shell used to build the actual Dockerfile.

=== Makefille ===

# This Free Software is published along the LGPL v3.0+ license.

export NODE=node:20.6.0-alpine3.18
export export PORT=8088
export HOST=

export AUTHOR="Jean-Pierre Rivière"
export WIKI=gendat
export WORKDIR=/mnt/userdata/tiddlywiki/${WIKI}
export CONTENT="nodejs instance with Tiddlywiki launching the ${WIKI} wiki"
export WORKDIR=/mnt/userdata/tiddlywiki/gendat

Dockerfile: Dockerfile.model
	sh $< | tee $@``

=== Dockerfile.model ===

echo "# Dockerfile for lanching the \"$WIKI\" wiki"
echo "# copied and adapted from elasticdog/tiddlywiki model available on docker hub"
echo from $NODE
echo label author="$AUTHOR"
echo label content="$CONTENT"
echo expose $PORT
echo workdir $WORKDIR
echo volume $WORKDIR
echo run apk update "&&" apk add --no-cache tini
echo run npm install -g tiddlywiki@$TIDDLYWIKI_VERSION "&&" npm install clean --force
echo entrypoint '["/sbin/tini", "--"]'
echo "cmd [\"tiddlywiki\", \"$WIKI\", \"--listen\", \"host=$HOST\", \"port=$PORT\"]"

Usage : First, adapt the makefile variable to your setup. And then execute make in your shell.

Maybe you can try not using cmd and using exec instead, which is more flexible. https://github.com/oeyoews/tiddlywiki-starter-kit/blob/422a0e72aec86c14a20219022474074f2e404956/Dockerfile#L14C2-L14C2

thank you @oeyoews for this new builder file. But… I can’t see any exec within? Just directly a startup script… I should explore it to be sure. But what exactly were yo trying to indicate?