Skip to main content

Simple Image Server

The simple-image-server is used by cctv-apps-streamlit to populate the carousel of images. Initially, the image server was chosen to avoid copying numerous image files into the project's public/static directory. With the image server, we are able to leave the images where they are and use NGINX to make them accessible in the network.

Server as a Service

Service Management

The service should always start on boot based on if the service has been enabled or not.

Enable the service to start on boot with the command: sudo systemctl enable simple-image-server.service

Start the service with the command: sudo systemctl start simple-image-server.service

Stop the service with the command: sudo systemctl stop simple-image-server.service

Check the service status with the command: sudo systemctl status simple-image-server.service

Service Definition

A new service file was created at /etc/systemd/system/simple-image-server.service:

[Unit]
Description=Redis container
Requires=docker.service
After=docker.service

[Service]
Restart=always
ExecStart=/usr/bin/docker compose -f /home/gqc/git/gqc/cctv-apps/docker-compose.yml up image-server
ExecStop=/usr/bin/docker compose -f /home/gqc/git/gqc/cctv-apps/docker-compose.yml down image-server

[Install]
WantedBy=default.target

Manual Control

⚠️ These manual controls are outdated, unless you're running it locally. For the MSI Server or any other shared locations, use the previous section to manage the server as a service.

Originally, the image server was managed manually. One would have to run docker run with a path to the images directory to start the server. Later, however, we switched to using a docker-compose.yml file, which can be found on the MSI Server at /home/gqc/git/gqc/cctv-apps/docker-compose.yml:

services:
image-server:
build: ../simple-image-server
volumes:
- /home/gqc/CCTV:/var/www
# NOTE: If port 8000 is already in use on your local machine, try "8001:8000"
ports:
- "8000:8000"
# - "8001:8000"

streamlit:
build: .
volumes:
- .:/app
- /home/gqc/CCTV/SD1/Data/2023_05_26/Video_DB/Video_DB_SD1_2023_05_26_all_vid_groups_gold_standard.db:/Databases/Video_DB_SD1.db
- /home/gqc/CCTV/ebmud/Data/Dataset_100923/Video_DB/Video_DB.db:/Databases/Video_DB_EBMUD.db
ports:
- "8501:8501"
environment:
- ENV_VAR=val
depends_on:
- image-server

You'll notice that the docker-compose file has two services in it, the image server and the streamlit app. To start the image server alone, you can use the following command:

docker compose up image-server -d

Specifying image-server after up ensures only the image server starts but not the streamlit app.

Use the -d parameter to start the container in detached mode.

Omit the -d parameter if you want to start the container in detached mode, which would mean you see the output and could kill the service with Ctrl+C.