-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
91 lines (70 loc) · 2.38 KB
/
Copy pathDockerfile
File metadata and controls
91 lines (70 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# 🐳 DocSync - Enterprise Docker Image
# Multi-stage build for optimized production image
# Stage 1: Build Dependencies
FROM python:3.11-slim-bullseye AS builder
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -r docsync && useradd -r -g docsync docsync
# Set working directory
WORKDIR /app
# Copy dependency files
COPY pyproject.toml README.md ./
COPY src/ ./src/
# Install Python dependencies
RUN pip install --upgrade pip setuptools wheel && \
pip install build && \
python -m build && \
pip install dist/*.whl && \
rm -rf dist/ build/ src/
# Stage 2: Production Image
FROM python:3.11-slim-bullseye AS production
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
DOCSYNC_ENV=production \
DOCSYNC_LOG_LEVEL=INFO
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Create non-root user
RUN groupadd -r docsync && useradd -r -g docsync docsync
# Set working directory
WORKDIR /app
# Copy from builder stage
COPY --from=builder /usr/local/lib/python3.11/site-packages/ /usr/local/lib/python3.11/site-packages/
COPY --from=builder /usr/local/bin/docsync /usr/local/bin/docsync
# Create necessary directories
RUN mkdir -p /app/data /app/config /app/logs && \
chown -R docsync:docsync /app
# Copy configuration templates
COPY --chown=docsync:docsync templates/ /app/templates/
COPY --chown=docsync:docsync examples/ /app/examples/
# Switch to non-root user
USER docsync
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD docsync --version || exit 1
# Expose port (if web interface is added)
EXPOSE 8000
# Set default command
CMD ["docsync", "--help"]
# Labels for metadata
LABEL maintainer="NEO-SH1W4" \
description="Advanced technical documentation synchronization system" \
version="0.1.0" \
org.opencontainers.image.source="https://github.com/NEO-SH1W4/docsync" \
org.opencontainers.image.documentation="https://github.com/NEO-SH1W4/docsync#readme" \
org.opencontainers.image.licenses="MIT"