File size: 1,632 Bytes
1ea26af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ============================================================================
# CognitiveKernel-Pro Web Server Dockerfile
# ============================================================================
# Based on Playwright official image with automatic browser version matching
# ============================================================================

# Use specific Playwright image version (includes browsers)
FROM mcr.microsoft.com/playwright:v1.46.1-focal

# Set environment variables
ENV NODE_ENV=production \
    LISTEN_PORT=9000 \
    MAX_BROWSERS=16 \
    USER_UID=1001 \
    USER_GID=1001 \
    APP_USER=ckweb \
    DOCKER_CONTAINER=true

# Create non-privileged user
RUN groupadd -g ${USER_GID} ${APP_USER} && \
    useradd -u ${USER_UID} -g ${USER_GID} -m -s /bin/bash ${APP_USER}

# Set working directory
WORKDIR /app

# Copy package files and install dependencies
COPY package.json ./
RUN npm install --only=production && npm cache clean --force

# Copy application code
COPY --chown=${APP_USER}:${APP_USER} . .

# Create necessary directories
RUN mkdir -p ./DownloadedFiles ./screenshots && \
    chown -R ${APP_USER}:${APP_USER} ./DownloadedFiles ./screenshots

# Copy entrypoint script
COPY --chown=${APP_USER}:${APP_USER} entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

# Switch to non-privileged user
USER ${APP_USER}

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
    CMD curl -f http://localhost:${LISTEN_PORT}/health || exit 1

# Expose port
EXPOSE ${LISTEN_PORT}

# Set entrypoint
ENTRYPOINT ["/entrypoint.sh"]

# Default command
CMD ["npm", "start"]