First commit before testing
This commit is contained in:
parent
adfd686f76
commit
f222b6e79a
59
docker/Dockerfile
Normal file
59
docker/Dockerfile
Normal file
@ -0,0 +1,59 @@
|
||||
# Multi-stage build
|
||||
FROM node:14-alpine as frontend-builder
|
||||
WORKDIR /app/frontend
|
||||
COPY frontend/package*.json ./
|
||||
RUN npm install
|
||||
COPY frontend/ ./
|
||||
RUN npm run build
|
||||
|
||||
FROM python:3.8-slim
|
||||
|
||||
# Install HAProxy and Certbot
|
||||
RUN apt-get update && \
|
||||
apt-get install -y \
|
||||
haproxy \
|
||||
certbot \
|
||||
python3-certbot \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create necessary directories
|
||||
RUN mkdir -p /etc/haproxy/certs \
|
||||
&& mkdir -p /var/lib/haproxy \
|
||||
&& mkdir -p /run/haproxy
|
||||
|
||||
# Set up Python environment
|
||||
WORKDIR /app
|
||||
COPY backend/requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy backend code
|
||||
COPY backend/ ./backend/
|
||||
|
||||
# Copy frontend build
|
||||
COPY --from=frontend-builder /app/frontend/build ./frontend/build
|
||||
|
||||
# Copy HAProxy configuration
|
||||
COPY backend/templates/haproxy.cfg.j2 /etc/haproxy/haproxy.cfg.template
|
||||
|
||||
# Install curl for healthcheck
|
||||
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create data directory
|
||||
RUN mkdir -p /app/backend/data
|
||||
|
||||
# Set permissions
|
||||
RUN chown -R nobody:nogroup /app/backend/data
|
||||
|
||||
# Add healthcheck
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:5000/health || exit 1
|
||||
|
||||
# Create run script
|
||||
RUN echo '#!/bin/sh\n\
|
||||
python backend/app.py &\n\
|
||||
haproxy -f /etc/haproxy/haproxy.cfg -db\n' > /start.sh && \
|
||||
chmod +x /start.sh
|
||||
|
||||
EXPOSE 80 443 5000
|
||||
|
||||
CMD ["/start.sh"]
|
32
docker/docker-compose.yml
Normal file
32
docker/docker-compose.yml
Normal file
@ -0,0 +1,32 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
haproxy-manager:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: docker/Dockerfile
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
- "5000:5000"
|
||||
volumes:
|
||||
- haproxy-certs:/etc/haproxy/certs
|
||||
- letsencrypt:/etc/letsencrypt
|
||||
- sqlite-data:/app/backend/data
|
||||
environment:
|
||||
- FLASK_ENV=production
|
||||
- SECRET_KEY=changeme
|
||||
- DATABASE_URL=sqlite:///data/haproxy-manager.db
|
||||
- JWT_SECRET_KEY=change-this-in-production
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 5s
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
haproxy-certs:
|
||||
letsencrypt:
|
||||
sqlite-data:
|
Loading…
x
Reference in New Issue
Block a user