Docker configuration to run LittleLink in a container.
Dockerfile: Defines how the image is built using nginx:alpinecompose.yaml: Configuration for Docker Compose with volumes for development.dockerignore: Excludes unnecessary files from the image
- Uses
nginx:alpinefor minimal image size (~20MB) - Includes gzip compression for static files
- Optimized cache configuration for CSS, JavaScript, and images
- Configured to forward nginx logs to Docker log collector
- Mounts the project root directory as a volume for live development
- Exposes port 80 in the container, mapped to 8080 on the host
One of the main advantages of this Docker setup is how easily you can create multiple personalized instances of LittleLink:
# Clone the repository
git clone https://github.com/sethcottle/littlelink.git littlelink-john
# Customize the content for John
cd littlelink-john
# Edit index.html with John's links, customize images, etc.
# Build a Docker image for John's page
docker build -f docker/Dockerfile -t littlelink-john .
# Run John's page on port 8080
docker run -d --name john-links -p 8080:80 littlelink-johnFor additional pages:
# Similarly for another person
git clone https://github.com/sethcottle/littlelink.git littlelink-jane
cd littlelink-jane
# Customize for Jane...
# Build and run on a different port
docker build -f docker/Dockerfile -t littlelink-jane .
docker run -d --name jane-links -p 8081:80 littlelink-janeThis approach allows you to:
- Maintain separate customized sites for different people
- Run multiple instances on different ports
- Update each site independently
- Easily deploy to various environments
There are two main ways to use Docker with LittleLink:
In development, we use Docker Compose with mounted volumes to allow for live editing:
# Start development environment
docker compose -f docker/compose.yaml upThis configuration:
- Mounts local files as a volume, so changes are reflected immediately
- Requires manual browser refresh to see changes
- Is ideal for testing and development
For production, you have two options:
Create a production-specific docker-compose file:
# docker/compose.prod.yaml
services:
web:
image: yourname/littlelink:latest
restart: always
ports:
- "8080:80"
# Optional volume for customizable content
volumes:
- /path/on/server/custom-content:/usr/share/nginx/htmlDeploy using:
# Build and tag the image
docker build -f docker/Dockerfile -t yourname/littlelink:latest .
# Run in production with compose
docker compose -f docker/compose.prod.yaml up -d# Build a production image
docker build -f docker/Dockerfile -t yourname/littlelink:latest .
# Run in production (no volumes mounted)
docker run -d --name littlelink -p 80:80 --restart always yourname/littlelink:latestYou can customize the content in production by mounting a local directory:
# Prepare a directory with your custom content
mkdir -p /path/on/server/custom-content
cp -r index.html css/ images/ /path/on/server/custom-content/
# Run with the custom content mounted
docker run -d --name littlelink -p 80:80 \
-v /path/on/server/custom-content:/usr/share/nginx/html \
yourname/littlelink:latestWith Docker Compose:
services:
web:
image: yourname/littlelink:latest
ports:
- "80:80"
volumes:
- /path/on/server/custom-content:/usr/share/nginx/htmlThis approach:
- Allows content customization without rebuilding the image
- Makes it easy to update content independently of the container
# Start in development mode
docker compose -f docker/compose.yaml up
# Start in background
docker compose -f docker/compose.yaml up -d
# Stop container
docker compose -f docker/compose.yaml down
# View logs (including HTTP request logs)
docker compose -f docker/compose.yaml logs -f# Build production image
docker build -f docker/Dockerfile -t yourname/littlelink:latest .
# Run production container
docker run -d --name littlelink -p 80:80 yourname/littlelink:latest
# View logs for the running container
docker logs -f littlelinkEdit docker/compose.yaml for development:
ports:
- "8081:80" # Change 8080 to desired portOr specify port when running production container:
docker run -p 8081:80 yourname/littlelink:latestTo modify the nginx configuration, you can edit the Dockerfile and add your own configuration:
# Example: add custom configuration
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf# Pull image
docker pull yourname/littlelink:latest
# Run container
docker run -d --name littlelink -p 80:80 yourname/littlelink:latest
# With restart policy for auto-recovery
docker run -d --name littlelink --restart unless-stopped -p 80:80 yourname/littlelink:latestYou can run multiple LittleLink instances on the same server:
# Run first site on port 8080
docker run -d --name site1 -p 8080:80 littlelink-site1
# Run second site on port 8081
docker run -d --name site2 -p 8081:80 littlelink-site2