docker cofig udpated
This commit is contained in:
38
Dockerfile
38
Dockerfile
@ -1,8 +1,20 @@
|
|||||||
# Build stage
|
# Build stage
|
||||||
FROM python:3.9-slim AS builder
|
FROM python:3.9-slim AS builder
|
||||||
|
|
||||||
# Install MkDocs, Material for MkDocs, and plugins
|
# Install build dependencies
|
||||||
RUN pip install --no-cache-dir mkdocs mkdocs-material mkdocs-macros-plugin
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
gcc \
|
||||||
|
python3-dev \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install MkDocs and plugins with exact versions for faster resolution
|
||||||
|
RUN pip install --no-cache-dir \
|
||||||
|
mkdocs==1.6.1 \
|
||||||
|
mkdocs-material==9.5.39 \
|
||||||
|
mkdocs-macros-plugin==1.2.0 \
|
||||||
|
mkdocs-minify-plugin==0.8.0 \
|
||||||
|
mkdocs-awesome-pages-plugin==2.9.2 \
|
||||||
|
mkdocs-glightbox==0.4.0
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /docs
|
WORKDIR /docs
|
||||||
@ -11,24 +23,24 @@ WORKDIR /docs
|
|||||||
COPY mkdocs.yml .
|
COPY mkdocs.yml .
|
||||||
COPY docs/ ./docs/
|
COPY docs/ ./docs/
|
||||||
|
|
||||||
# Validate configuration and build site with strict mode
|
# Build the static site with strict mode
|
||||||
RUN mkdocs build --strict
|
RUN mkdocs build --strict
|
||||||
|
|
||||||
# Production stage
|
# Runtime stage
|
||||||
FROM nginx:alpine
|
FROM python:3.9-slim
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /site
|
||||||
|
|
||||||
# Copy the built site from the builder stage
|
# Copy the built site from the builder stage
|
||||||
COPY --from=builder /docs/site /usr/share/nginx/html
|
COPY --from=builder /docs/site .
|
||||||
|
|
||||||
# Copy custom Nginx configuration
|
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
||||||
|
|
||||||
# Expose port 80
|
# Expose port 80
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
# Healthcheck to ensure Nginx is running
|
# Healthcheck to ensure the server is running
|
||||||
HEALTHCHECK --interval=30s --timeout=3s \
|
HEALTHCHECK --interval=30s --timeout=3s \
|
||||||
CMD curl -f http://localhost/ || exit 1
|
CMD curl -f http://localhost:80/ || exit 1
|
||||||
|
|
||||||
# Start Nginx
|
# Serve the static site with Python's http.server
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["python", "-m", "http.server", "80"]
|
||||||
@ -8,14 +8,14 @@ services:
|
|||||||
image: mkdocs-material-prod
|
image: mkdocs-material-prod
|
||||||
ports:
|
ports:
|
||||||
- "8085:80"
|
- "8085:80"
|
||||||
environment:
|
|
||||||
- NGINX_WORKER_PROCESSES=1
|
|
||||||
- NGINX_WORKER_CONNECTIONS=1024
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
- ./mkdocs.yml:/docs/mkdocs.yml:ro
|
||||||
|
- ./docs:/docs/docs:ro
|
||||||
|
environment:
|
||||||
|
- PYTHONUNBUFFERED=1
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost/"]
|
test: ["CMD", "curl", "-f", "http://localhost:80/"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 3s
|
timeout: 3s
|
||||||
retries: 3
|
retries: 3
|
||||||
Reference in New Issue
Block a user