Docker Configuration for Hugo #3

Closed
opened 2025-06-01 18:20:57 +02:00 by bennolor · 0 comments
Owner

Description:

Create Docker configuration for both development and production environments to containerize our Hugo blog.

Tasks:

  1. Create a Dockerfile for the Hugo site:
FROM klakegg/hugo:0.101.0-ext-alpine-ci AS builder

WORKDIR /src
COPY . .
RUN hugo --minify

FROM nginx:alpine
COPY --from=builder /src/public /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
  1. Create nginx.conf for the container:
server {
    listen 80;
    server_name localhost;
    root /usr/share/nginx/html;
    
    location / {
        index index.html;
        try_files $uri $uri/ =404;
    }
}
  1. Create docker-compose.yml for local development:
version: '3'
services:
  hugo:
    image: klakegg/hugo:0.101.0-ext-alpine-ci
    command: server -D --bind 0.0.0.0
    volumes:
      - .:/src
    ports:
      - "1313:1313"
  1. Create docker-compose.prod.yml for production:
version: '3'
services:
  blog:
    build: .
    restart: always
    networks:
      - web
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.blog.rule=Host(`blog.yourdomain.com`)"
      - "traefik.http.routers.blog.entrypoints=websecure"
      - "traefik.http.routers.blog.tls.certresolver=myresolver"

networks:
  web:
    external: true
  1. Test Docker build and run locally:
    • docker build -t hugo-blog .
    • docker run -p 8080:80 hugo-blog
  2. Test docker-compose development setup:
    • docker-compose up
  3. Add Docker-related files to Git and push

Definition of Done:

  • Dockerfile created and tested
  • Docker Compose files for development and production created
  • Nginx configuration prepared
  • Docker build succeeds without errors
  • Site can be accessed locally through Docker container
  • All Docker-related files committed to repository
## **Description:** Create Docker configuration for both development and production environments to containerize our Hugo blog. ## **Tasks:** 1. Create a Dockerfile for the Hugo site: ```dockerfile FROM klakegg/hugo:0.101.0-ext-alpine-ci AS builder WORKDIR /src COPY . . RUN hugo --minify FROM nginx:alpine COPY --from=builder /src/public /usr/share/nginx/html COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 ``` 2. Create nginx.conf for the container: ``` server { listen 80; server_name localhost; root /usr/share/nginx/html; location / { index index.html; try_files $uri $uri/ =404; } } ``` 3. Create docker-compose.yml for local development: ```yaml version: '3' services: hugo: image: klakegg/hugo:0.101.0-ext-alpine-ci command: server -D --bind 0.0.0.0 volumes: - .:/src ports: - "1313:1313" ``` 4. Create docker-compose.prod.yml for production: ```yaml version: '3' services: blog: build: . restart: always networks: - web labels: - "traefik.enable=true" - "traefik.http.routers.blog.rule=Host(`blog.yourdomain.com`)" - "traefik.http.routers.blog.entrypoints=websecure" - "traefik.http.routers.blog.tls.certresolver=myresolver" networks: web: external: true ``` 5. Test Docker build and run locally: - `docker build -t hugo-blog .` - `docker run -p 8080:80 hugo-blog` 6. Test docker-compose development setup: - `docker-compose up` 7. Add Docker-related files to Git and push ## **Definition of Done:** - Dockerfile created and tested - Docker Compose files for development and production created - Nginx configuration prepared - Docker build succeeds without errors - Site can be accessed locally through Docker container - All Docker-related files committed to repository
bennolor added this to the Initial Development and Deployment project 2025-06-01 18:30:14 +02:00
bennolor added this to the Release milestone 2025-06-01 18:30:16 +02:00
bennolor started working 2025-06-01 19:55:13 +02:00
bennolor worked for 20 minutes 2025-06-01 20:15:35 +02:00
bennolor moved this to Done in Initial Development and Deployment on 2025-06-01 21:42:13 +02:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Total Time Spent: 20 minutes
bennolor
20 minutes
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: bennolor/hugoblog#3