-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
109 lines (85 loc) · 3.25 KB
/
Dockerfile
File metadata and controls
109 lines (85 loc) · 3.25 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# MakerMatrix Dockerfile
# Multi-stage build for production deployment
# Build arguments for metadata
ARG VERSION=1.0.0
ARG BUILD_DATE
ARG VCS_REF
# Stage 1: Frontend Build
FROM node:18-alpine AS frontend-builder
WORKDIR /frontend
# Copy frontend package files
COPY MakerMatrix/frontend/package*.json ./
# Install frontend dependencies (skip prepare scripts like husky, include devDeps for build)
RUN npm ci --ignore-scripts
# Copy frontend source
COPY MakerMatrix/frontend/ ./
# Build frontend for production (skip type checking for now - TODO: fix TS errors)
RUN npx vite build
# Stage 2: Backend Runtime
FROM python:3.12-slim
# Re-declare build arguments for this stage
ARG VERSION=1.0.0
ARG BUILD_DATE
ARG VCS_REF
# Add OCI labels for metadata
LABEL org.opencontainers.image.title="MakerMatrix" \
org.opencontainers.image.description="Comprehensive parts and inventory management system for makers and engineers" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.revision="${VCS_REF}" \
org.opencontainers.image.vendor="MakerMatrix Contributors" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.url="https://github.com/ril3y/MakerMatrix" \
org.opencontainers.image.documentation="https://github.com/ril3y/MakerMatrix/blob/main/README.md" \
org.opencontainers.image.source="https://github.com/ril3y/MakerMatrix" \
maintainer="MakerMatrix Contributors"
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
MAKERMATRIX_VERSION=${VERSION}
# Install system dependencies (including build tools for pyminizip and fonts for label printing)
RUN apt-get update && apt-get install -y \
curl \
gcc \
g++ \
zlib1g-dev \
fonts-dejavu-core \
&& rm -rf /var/lib/apt/lists/*
# Create app user
RUN useradd -m -u 1000 makermatrix && \
mkdir -p /app /data && \
chown -R makermatrix:makermatrix /app /data
# Set working directory
WORKDIR /app
# Copy requirements
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy backend application
COPY --chown=makermatrix:makermatrix MakerMatrix/ ./MakerMatrix/
# Copy frontend build from builder stage
COPY --from=frontend-builder --chown=makermatrix:makermatrix /frontend/dist ./MakerMatrix/frontend/dist
# Create necessary directories with proper permissions
RUN mkdir -p \
/data/database \
/data/backups \
/data/static/datasheets \
/data/static/images \
/data/certs \
&& chown -R makermatrix:makermatrix /data
# Switch to non-root user
USER makermatrix
# Expose ports
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8080/api/utility/get_counts || exit 1
# Set environment variables for data paths
ENV DATABASE_URL=sqlite:////data/database/makermatrix.db \
STATIC_FILES_PATH=/data/static \
BACKUPS_PATH=/data/backups \
CERTS_PATH=/data/certs
# Run the application
CMD ["python", "-m", "MakerMatrix.main"]