mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-30 14:22:02 +00:00
This commit refactors the handling of ALLOWED_ROOT_DIRECTORY by removing legacy support for ALLOWED_PROJECT_DIRS and simplifying the security logic. Key changes include: - Removed deprecated ALLOWED_PROJECT_DIRS references from .env.example and security.ts. - Updated initAllowedPaths() to focus solely on ALLOWED_ROOT_DIRECTORY and DATA_DIR. - Enhanced logging for ALLOWED_ROOT_DIRECTORY configuration status. - Adjusted route handlers to utilize the new workspace directory logic. - Introduced a centralized storage module for localStorage operations to improve consistency and error handling. These changes aim to enhance security and maintainability by consolidating directory management into a single variable. Tests: All unit tests passing.
68 lines
1.8 KiB
Docker
68 lines
1.8 KiB
Docker
# Automaker Backend Server
|
|
# Multi-stage build for minimal production image
|
|
|
|
# Build stage
|
|
FROM node:20-alpine AS builder
|
|
|
|
# Install build dependencies for native modules (node-pty)
|
|
RUN apk add --no-cache python3 make g++
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files and scripts needed for postinstall
|
|
COPY package*.json ./
|
|
COPY apps/server/package*.json ./apps/server/
|
|
COPY scripts ./scripts
|
|
|
|
# Install dependencies
|
|
RUN npm ci --workspace=apps/server
|
|
|
|
# Copy source
|
|
COPY apps/server ./apps/server
|
|
|
|
# Build TypeScript
|
|
RUN npm run build --workspace=apps/server
|
|
|
|
# Production stage
|
|
FROM node:20-alpine
|
|
|
|
# Install git, curl, and GitHub CLI
|
|
RUN apk add --no-cache git curl && \
|
|
GH_VERSION=$(curl -s https://api.github.com/repos/cli/cli/releases/latest | grep '"tag_name"' | cut -d '"' -f 4 | sed 's/v//') && \
|
|
curl -L "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.tar.gz" -o gh.tar.gz && \
|
|
tar -xzf gh.tar.gz && \
|
|
mv gh_*_linux_amd64/bin/gh /usr/local/bin/gh && \
|
|
rm -rf gh.tar.gz gh_*_linux_amd64
|
|
|
|
WORKDIR /app
|
|
|
|
# Create non-root user
|
|
RUN addgroup -g 1001 -S automaker && \
|
|
adduser -S automaker -u 1001
|
|
|
|
# Copy built files and production dependencies
|
|
COPY --from=builder /app/apps/server/dist ./dist
|
|
COPY --from=builder /app/apps/server/package*.json ./
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
|
|
# Create data directory
|
|
RUN mkdir -p /data && chown automaker:automaker /data
|
|
|
|
# Switch to non-root user
|
|
USER automaker
|
|
|
|
# Environment variables
|
|
ENV NODE_ENV=production
|
|
ENV PORT=3008
|
|
ENV DATA_DIR=/data
|
|
|
|
# Expose port
|
|
EXPOSE 3008
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD wget --no-verbose --tries=1 --spider http://localhost:3008/api/health || exit 1
|
|
|
|
# Start server
|
|
CMD ["node", "dist/index.js"]
|