Skip to content

vcgalpin/tempdb_simple_web_docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README.md

tempdb_simple_web_docker

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.

  1. 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_app and pull the image with tag tempdb_simple_web_test. Find the image under Images in Docker Desktop and run it with the following settings.

      optional_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_test
      

      and 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.)

  2. 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
      docker build --no-cache -t tempdb_simple_web .
      
      followed by
      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 tool extension in Visual Studio Code: https://code.visualstudio.com/docs/containers/overview

What the container does

When the container starts, it:

  1. starts PostgreSQL
  2. creates the database role if needed
  3. creates the database if needed
  4. loads the SQL dump if the database does not already exist
  5. starts the Links web app

Database persistence and refresh

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_pgdata

Running the bash script

Run ./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

What happens on first run of the bash script

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

What happens on later runs

If you answer n

The script will:

  • reuse the existing image
  • reuse the existing container if possible
  • reuse the existing database volume

If you answer y

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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors