This directory contains a shell-first Docker setup for Links temporal DB web application. It is intended for interactive use.
The container provides the Links application code, PostgreSQL, bash, git, psql, linx and an interactive shell environment.
The web app does not start automatically when you enter the container. Instead, you are dropped into a shell and can choose what to run.
The container provides a link to the app at http://localhost:8081 when the app is running.
There are two different ways to run this container from an image.
-
Build the image yourself on your own computer using the Dockerfile,
- either run the bash script - more details on what the script does
./run-web-shell.sh - or use the following command
followed by
docker build --no-cache -t tempdb_web_shell .docker run -it \ --name tempdb_web_shell \ -p 8081:8080 \ -v tempdb_web_shell_pgdata:/opt/postgres-data \ tempdb_web_shell:latest
Another option is to use the
containers toolextension in Visual Studio Code: https://code.visualstudio.com/docs/containers/overview - either run the bash script - more details on what the script does
-
Download the image and run it. The image generated by this setup is available at https://hub.docker.com/repository/docker/vcgalpin/xps_dcc_app/ with the tag
tempdb_web_shell_test- use
and to restart it or to view the logs, use
docker run -it \ --name tempdb_web_shell \ -p 8081:8080 \ -v tempdb_web_shell_pgdata:/opt/postgres-data \ vcgalpin/xps_dcc_app:tempdb_web_shell_testdocker start -ai tempdb_web_shell docker logs -f tempdb_simple_web - It is not clear whether it is possible to start an interactive container via Docker Desktop.
(Note: This image does not provide the functionality of
run-web-shell.sh. This functionality can only be accessed when building the image from the Dockerfile rather than just running the downloaded image as a container.) - use
When the container starts, it:
- starts PostgreSQL
- creates the database role if needed
- creates the database if needed
- loads the SQL dump if the database does not already exist
- opens an interactive shell with the correct
opamenvironment loaded
This means linx should be available directly in the shell.
linx --config=config.debug.0.9.8 src/startXPS.linkslinxpsql -h /tmp -p 5432 -d linksdb -U linksuserpsql -h /tmp -p 5432 -d linksdb -U linksuser -c '\dt'git statusThe container is started with this mapping:
- host port
8081 - container port
8080
So if you start the web app inside the container, it should be reachable at http://localhost:8081
The PostgreSQL data is stored in the Docker volume:
tempdb_web_shell_pgdata
This means:
- the database persists across container restarts
- rebuilding the image does not automatically reset the database
- recreating the volume removes the existing database state
When you run ./run-web-shell.sh the script can:
-
optionally show the current local Docker status of the image, the container and the data volume
-
check GitHub for the latest version of the configured branch
-
compare the current local image commit with the latest remote commit
-
classify changes as:
- no changes
- only code changed
- only SQL dump changed
- both code and SQL dump changed
-
show a second status section describing:
- local commit
- remote commit
- detected change type
- currently selected actions
-
let the user choose manual override actions:
- rebuild image anyway
- recreate database volume anyway
- both
- neither
-
ask any additional targeted questions if needed
-
start or attach to the shell container
Make the scripts executable:
chmod +x run-web-shell.sh show-status.sh show-change-status.sh show-commands.shdocker psdocker exec -it tempdb_web_shell bashdocker logs tempdb_web_shelldocker stop tempdb_web_shelldocker rm -f tempdb_web_shelldocker volume rm tempdb_web_shell_pgdataThe main values are currently set in run-web-shell.sh:
- image name
- container name
- volume name
- GitHub repo URL
- GitHub branch
- SQL dump path
- database name
- database user
- database password
- web app start command
If you need to change behaviour, those are the first places to look.
The container runs as linksuser
The DB user is linksuser
The interactive shell is bash
Use linx, not links