This repo contains a simple Docker setup for running the Links temporal DB web application as a demo in a single container.
The container includes the Links web app, the application code cloned from GitHub at build time and PostgreSQL.
The container provides a link to the app at http://localhost:8080
There are two different ways to run this container from an image.
-
Download the image and run it. The image created by this setup is available at https://hub.docker.com/repository/docker/vcgalpin/xps_dcc_app/ with tag
tempdb_simple_web_test.To run this image as a container,
-
either within Docker Desktop, search in Docker Hub for
xps_dcc_appand pull the image with tagtempdb_simple_web_test. Find the image under Images in Docker Desktop and run it with the following settings.
-
or use
docker run -d \ --name tempdb_simple_web \ -p 8080:8080 \ -v tempdb_simple_web_pgdata:/opt/postgres-data \ vcgalpin/xps_dcc_app:tempdb_simple_web_testand to stop and restart it or to view the logs, use
docker stop tempdb_simple_web docker start tempdb_simple_web docker logs -f tempdb_simple_web
(Note: This image does not provide the functionality of
run-web.sh. This functionality can only be accessed when building the image from the Dockerfile rather than just running the downloaded image as a container.) -
-
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.sh - or use the following command
followed by
docker build --no-cache -t tempdb_simple_web .docker run -d \ --name tempdb_simple_web \ -p 8080:8080 \ -v tempdb_simple_web_pgdata:/opt/postgres-data \ tempdb_simple_web: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
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
- starts the Links web app
The PostgreSQL data is stored in a Docker volume:
tempdb_simple_web_pgdata
That means:
- rebuilding the image does not automatically delete the database
- the SQL dump is only loaded the first time the database is created
If you want a completely fresh database, remove the container and the PostgreSQL volume. Run
docker rm -f tempdb_simple_web
docker volume rm tempdb_simple_web_pgdataRun ./run-web.sh (making the script executable if necessary: chmod +x entrypoint.sh run-web.sh)
You will be asked:
Rebuild image from GitHub before starting? [y/N]
If no image exists yet, it will be built automatically.
Then open http://localhost:8080
On the first run, the script will:
- build the Docker image if needed
- create the container
- create the PostgreSQL data volume
- start PostgreSQL
- create the database
- import the SQL dump
- start the Links web app
The script will:
- reuse the existing image
- reuse the existing container if possible
- reuse the existing database volume
The script will:
- rebuild the image from GitHub
- remove the old container
- create a new container
- keep the existing database volume unless you delete it yourself