This document explains how to use the environment configuration setup for different deployment scenarios including development, production, and staging environments.
This document explains how to use the environment configuration setup for different deployment scenarios including development, production, and staging environments.
This document explains how to use the environment configuration setup for different deployment scenarios.
We’ve organized environment configurations into separate files in the env directory:
env/.env.development - Development environment settingsenv/.env.production - Production environment settingsenv/.env.staging - Staging environment settingsTo set up the environment structure, run:
1./scripts/install-env-setup.sh
This script will:
env directory with environment filesscripts directory.env to the development environment fileSource the helper functions:
1source scripts/env-helpers.sh
Then use the following commands:
hugo-dev - Start the development serverhugo-prod - Start the production serverhugo-staging - Start the staging serverhugo-build-prod - Build the production sitehugo-build-staging - Build the staging sitehugo-env - Show the current environmenthugo-stop - Stop all containershugo-cleanup - Clean up Docker resourcesYou can manually specify the environment file when running Docker Compose:
1# Development
2ENV_FILE=env/.env.development docker compose up -d server
3
4# Production
5ENV_FILE=env/.env.production docker compose up -d server
6
7# Staging
8ENV_FILE=env/.env.staging docker compose up -d server
You can change the default environment by updating the symlink:
1# Switch to production
2ln -sf env/.env.production .env
3
4# Switch to development
5ln -sf env/.env.development .env
6
7# Switch to staging
8ln -sf env/.env.staging .env
Then run Docker Compose normally:
1docker compose up -d server
config/development/hugo.yamlconfig/production/hugo.yamlconfig/production/hugo.yamlYou can customize any environment by editing the corresponding file in the env directory. Common settings to adjust include:
HUGO_DEV_PORT - The port to access the serverDOCKER_MEMORY_LIMIT - Memory allocation for the containerDOCKER_CPU_LIMIT - CPU allocation for the containerHUGO_BUILDDRFTS - Whether to include draft contentHUGO_VERBOSE - Enable verbose loggingHUGO_MINIFY - Enable minificationTo test if your environment configuration is working correctly:
Start a server with a specific environment:
1ENV_FILE=env/.env.production docker compose up -d server
Check the server is running on the expected port:
1curl http://localhost:3003
Check the container’s resource allocation:
1docker stats
Verify the Hugo configuration being used:
1docker compose logs server | grep "config"
1docker logs docker-with-hugo-server-1
2
3# Using curl
4curl http://localhost:2003
5
6# Using curl
7curl http://localhost:2003
8
9curl http://localhost:2003 | head -20
10
11# Check if anything is listening on port 2003
12netstat -tuln | grep 2003
13
14# Using wget
15wget -O- http://localhost:2003
16
17sudo ufw status
18
19sudo ufw allow 2003/tcp
20
21# Find your IP
22ip addr show | grep -E "inet .* global" | awk '{print $2}' | cut -d/ -f1
23
24sudo lsof -i :2003
25
26docker exec hugo-dev-server-1 env | grep HUGO
docker logs docker-with-hugo-server-1: Displays the logs of the Docker container nameddocker-with-hugo-server-1. Useful for debugging or monitoring the container’s output.curl http://localhost:2003: Sends an HTTP GET request tolocalhoston port2003. This checks if the server is responding.curl http://localhost:2003 | head -20: Sends an HTTP GET request tolocalhoston port2003and displays the first 20 lines of the response. Useful for quickly inspecting the server’s output.netstat -tuln | grep 2003: Checks if any process is listening on port2003. The-tulnflags show TCP/UDP connections in numeric form.wget -O- http://localhost:2003: Fetches the content fromhttp://localhost:2003and outputs it directly to the terminal (-O-).sudo ufw status: Displays the status of the UFW (Uncomplicated Firewall) to check which ports are open or blocked.sudo ufw allow 2003/tcp: Opens port2003for TCP traffic in the UFW firewall, allowing external connections.ip addr show | grep -E "inet .* global" | awk '{print $2}' | cut -d/ -f1: Finds the system’s global IP address by filtering the output ofip addr show.sudo lsof -i :2003: Lists all processes using port2003. Useful for identifying which application is bound to the port.docker exec hugo-dev-server-1 env | grep HUGO: Executes the env command inside the Docker containerhugo-dev-server-1and filters for environment variables containingHUGO.