Skip to content

Commit

Permalink
Adding stuff for deployment.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bioblaze committed Oct 14, 2024
1 parent c5babea commit 85b85ba
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Stage 1: Build documentation using Sphinx
FROM ubuntu:22.04 AS sphinx-build

# Set working directory
WORKDIR /docs

# Install necessary dependencies
RUN apt-get update && apt-get install -y \
python3-pip \
make \
dos2unix \
recode \
parallel \
libwebp7 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Copy requirements.txt and install pip dependencies
COPY requirements.txt .

RUN pip3 install -r requirements.txt
RUN pip3 install codespell

# Copy the rest of the documentation files
COPY . .

# Create the output directory
RUN mkdir -p _build/html

# Build HTML documentation using Sphinx
RUN make SPHINXOPTS='--color' html

# Stage 2: Serve the built documentation using Nginx
FROM nginx:alpine

# Copy built HTML documentation from the previous stage
COPY --from=sphinx-build /docs/_build/html /usr/share/nginx/html

# Add custom Nginx config for health check
COPY nginx.conf /etc/nginx/nginx.conf

# Expose port 8080 for serving
EXPOSE 8080

# Healthcheck to ensure Nginx is serving correctly
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1

# Start Nginx
CMD ["nginx", "-g", "daemon off;"]
28 changes: 28 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {
include mime.types; # Include default mime types
default_type application/octet-stream; # Default type if not matched

server {
listen 8080;

# Serve the documentation files
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ =404; # Handle missing files
}

# Health check endpoint
location /health {
access_log off; # Disable access logs for health check
return 200 'OK';
add_header Content-Type text/plain;
}
}
}

0 comments on commit 85b85ba

Please sign in to comment.