fix opsm
This commit is contained in:
55
Dockerfile
55
Dockerfile
@@ -15,7 +15,6 @@ ENV DEBIAN_FRONTEND=noninteractive \
|
|||||||
LC_ALL=C.UTF-8
|
LC_ALL=C.UTF-8
|
||||||
|
|
||||||
# Install minimal system dependencies only (no PowerShell or Node.js from apt)
|
# Install minimal system dependencies only (no PowerShell or Node.js from apt)
|
||||||
# Includes OpenSMTPD dependencies for email server functionality
|
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends \
|
&& apt-get install -y --no-install-recommends \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
@@ -28,21 +27,6 @@ RUN apt-get update \
|
|||||||
tini \
|
tini \
|
||||||
libicu-dev \
|
libicu-dev \
|
||||||
libssl-dev \
|
libssl-dev \
|
||||||
python3-pip \
|
|
||||||
iproute2 \
|
|
||||||
php \
|
|
||||||
php-cli \
|
|
||||||
php-common \
|
|
||||||
php-mbstring \
|
|
||||||
php-xml \
|
|
||||||
php-zip \
|
|
||||||
php-gd \
|
|
||||||
php-curl \
|
|
||||||
opensmtpd \
|
|
||||||
opensmtpd-extras \
|
|
||||||
libevent-dev \
|
|
||||||
libasr-dev \
|
|
||||||
ca-certificates \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install PowerShell 7.x from official binary release (architecture-aware)
|
# Install PowerShell 7.x from official binary release (architecture-aware)
|
||||||
@@ -119,40 +103,6 @@ RUN cd /opt/webchat && npm install --production && chmod -R 755 /opt/webchat
|
|||||||
COPY chat_v2 /opt/webchat_v2
|
COPY chat_v2 /opt/webchat_v2
|
||||||
RUN chmod -R 755 /opt/webchat_v2
|
RUN chmod -R 755 /opt/webchat_v2
|
||||||
|
|
||||||
# Create OpenSMTPD expected directory structure for application compatibility
|
|
||||||
# The application expects OpenSMTPD at /workspace/src/backend/app/opensmtpd/install/
|
|
||||||
RUN mkdir -p /workspace/src/backend/app/opensmtpd/install/etc \
|
|
||||||
&& mkdir -p /workspace/src/backend/app/opensmtpd/install/var/spool/smtpd \
|
|
||||||
&& mkdir -p /workspace/src/backend/app/opensmtpd/install/var/spool/queue \
|
|
||||||
&& mkdir -p /workspace/src/backend/app/opensmtpd/install/var/run \
|
|
||||||
&& ln -sf /usr/sbin/smtpd /workspace/src/backend/app/opensmtpd/install/sbin/smtpd \
|
|
||||||
&& ln -sf /usr/sbin/smtpctl /workspace/src/backend/app/opensmtpd/install/sbin/smtpctl \
|
|
||||||
&& ln -sf /usr/bin/sendmail /workspace/src/backend/app/opensmtpd/install/sbin/sendmail \
|
|
||||||
&& ln -sf /etc/ssl/certs /workspace/src/backend/app/opensmtpd/install/etc/certs \
|
|
||||||
&& chmod -R 755 /workspace/src/backend/app/opensmtpd/install
|
|
||||||
|
|
||||||
# Create OpenSMTPD configuration
|
|
||||||
RUN echo 'pki plugincompass.com cert "/workspace/src/backend/app/opensmtpd/install/etc/certs/fullchain.pem"' > /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& echo 'pki plugincompass.com key "/workspace/src/backend/app/opensmtpd/install/etc/certs/privkey.pem"' >> /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& echo '' >> /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& echo 'table domains file:/workspace/src/backend/app/opensmtpd/install/etc/domains' >> /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& echo 'table aliases file:/workspace/src/backend/app/opensmtpd/install/etc/aliases' >> /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& echo '' >> /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& echo 'listen on 0.0.0.0 port 25' >> /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& echo 'listen on 0.0.0.0 port 587 tls-require pki plugincompass.com' >> /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& echo 'listen on 0.0.0.0 port 465 smtps pki plugincompass.com' >> /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& echo '' >> /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& echo 'action "local" mbox alias <aliases>' >> /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& echo 'action "relay" relay' >> /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& echo '' >> /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& echo 'match from any for domain <domains> action "local"' >> /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& echo 'match for local action "local"' >> /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& echo 'match auth from any for any action "relay"' >> /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& echo 'match from local for any action "relay"' >> /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf \
|
|
||||||
&& touch /workspace/src/backend/app/opensmtpd/install/etc/domains \
|
|
||||||
&& touch /workspace/src/backend/app/opensmtpd/install/etc/aliases \
|
|
||||||
&& chmod 644 /workspace/src/backend/app/opensmtpd/install/etc/smtpd.conf
|
|
||||||
|
|
||||||
# Create workspace directory and set as workdir so pwsh starts where repo/workspace is mounted
|
# Create workspace directory and set as workdir so pwsh starts where repo/workspace is mounted
|
||||||
RUN mkdir -p /home/web/data \
|
RUN mkdir -p /home/web/data \
|
||||||
&& mkdir -p /var/log/shopify-ai \
|
&& mkdir -p /var/log/shopify-ai \
|
||||||
@@ -161,10 +111,7 @@ WORKDIR /home/web/data
|
|||||||
|
|
||||||
# Container defaults - Shopify AI App Builder
|
# Container defaults - Shopify AI App Builder
|
||||||
# Port 4500: Web UI (chat/builder interface)
|
# Port 4500: Web UI (chat/builder interface)
|
||||||
# Port 25: SMTP (OpenSMTPD)
|
EXPOSE 4500
|
||||||
# Port 587: SMTP submission (OpenSMTPD)
|
|
||||||
# Port 465: SMTPS (OpenSMTPD)
|
|
||||||
EXPOSE 4500 25 587 465
|
|
||||||
HEALTHCHECK --interval=30s --timeout=15s --start-period=60s --retries=5 \
|
HEALTHCHECK --interval=30s --timeout=15s --start-period=60s --retries=5 \
|
||||||
CMD /usr/local/bin/healthcheck.sh || exit 1
|
CMD /usr/local/bin/healthcheck.sh || exit 1
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ services:
|
|||||||
build: .
|
build: .
|
||||||
ports:
|
ports:
|
||||||
- "4500:4500"
|
- "4500:4500"
|
||||||
# OpenSMTPD ports for email functionality
|
|
||||||
- "25:25"
|
|
||||||
- "587:587"
|
|
||||||
- "465:465"
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
- OPENCODE_API_KEY=${OPENCODE_API_KEY:-}
|
- OPENCODE_API_KEY=${OPENCODE_API_KEY:-}
|
||||||
|
|||||||
@@ -166,96 +166,6 @@ else
|
|||||||
mkdir -p "$REPO_DIR"
|
mkdir -p "$REPO_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "Setting up OpenSMTPD service..."
|
|
||||||
|
|
||||||
OPENSMTPD_SYSTEM_BINARY="/usr/sbin/smtpd"
|
|
||||||
OPENSMTPD_INSTALL_ROOT="/workspace/src/backend/app/opensmtpd/install"
|
|
||||||
if [ -d "${REPO_DIR}/backend/app/opensmtpd" ]; then
|
|
||||||
OPENSMTPD_INSTALL_ROOT="${REPO_DIR}/backend/app/opensmtpd/install"
|
|
||||||
fi
|
|
||||||
|
|
||||||
OPENSMTPD_CONFIG="${OPENSMTPD_INSTALL_ROOT}/etc/smtpd.conf"
|
|
||||||
OPENSMTPD_PID_FILE="${OPENSMTPD_INSTALL_ROOT}/var/run/smtpd.pid"
|
|
||||||
OPENSMTPD_CUSTOM_BINARY="${OPENSMTPD_INSTALL_ROOT}/sbin/smtpd"
|
|
||||||
|
|
||||||
ensure_opensmtpd_layout() {
|
|
||||||
if [ ! -x "$OPENSMTPD_SYSTEM_BINARY" ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "${OPENSMTPD_INSTALL_ROOT}/sbin"
|
|
||||||
mkdir -p "${OPENSMTPD_INSTALL_ROOT}/etc"
|
|
||||||
mkdir -p "${OPENSMTPD_INSTALL_ROOT}/var/spool/smtpd"
|
|
||||||
mkdir -p "${OPENSMTPD_INSTALL_ROOT}/var/spool/queue"
|
|
||||||
mkdir -p "${OPENSMTPD_INSTALL_ROOT}/var/run"
|
|
||||||
|
|
||||||
if [ ! -e "$OPENSMTPD_CUSTOM_BINARY" ]; then
|
|
||||||
ln -s "$OPENSMTPD_SYSTEM_BINARY" "$OPENSMTPD_CUSTOM_BINARY"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -x "/usr/sbin/smtpctl" ] && [ ! -e "${OPENSMTPD_INSTALL_ROOT}/sbin/smtpctl" ]; then
|
|
||||||
ln -s "/usr/sbin/smtpctl" "${OPENSMTPD_INSTALL_ROOT}/sbin/smtpctl"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -x "/usr/bin/sendmail" ] && [ ! -e "${OPENSMTPD_INSTALL_ROOT}/sbin/sendmail" ]; then
|
|
||||||
ln -s "/usr/bin/sendmail" "${OPENSMTPD_INSTALL_ROOT}/sbin/sendmail"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d "/etc/ssl/certs" ] && [ ! -e "${OPENSMTPD_INSTALL_ROOT}/etc/certs" ]; then
|
|
||||||
ln -s "/etc/ssl/certs" "${OPENSMTPD_INSTALL_ROOT}/etc/certs"
|
|
||||||
fi
|
|
||||||
|
|
||||||
chmod -R 755 "${OPENSMTPD_INSTALL_ROOT}/var" 2>/dev/null || true
|
|
||||||
}
|
|
||||||
|
|
||||||
ensure_opensmtpd_layout
|
|
||||||
|
|
||||||
# Determine which binary to use (prefer custom, fallback to system)
|
|
||||||
OPENSMTPD_BINARY=""
|
|
||||||
if [ -x "$OPENSMTPD_CUSTOM_BINARY" ]; then
|
|
||||||
OPENSMTPD_BINARY="$OPENSMTPD_CUSTOM_BINARY"
|
|
||||||
log "Using custom OpenSMTPD binary: $OPENSMTPD_BINARY"
|
|
||||||
elif [ -x "$OPENSMTPD_SYSTEM_BINARY" ]; then
|
|
||||||
OPENSMTPD_BINARY="$OPENSMTPD_SYSTEM_BINARY"
|
|
||||||
log "Using system OpenSMTPD binary: $OPENSMTPD_BINARY"
|
|
||||||
else
|
|
||||||
# Try to find in PATH
|
|
||||||
if command -v smtpd &>/dev/null; then
|
|
||||||
OPENSMTPD_BINARY="$(command -v smtpd)"
|
|
||||||
log "Using OpenSMTPD from PATH: $OPENSMTPD_BINARY"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$OPENSMTPD_BINARY" ] && [ -f "$OPENSMTPD_CONFIG" ]; then
|
|
||||||
log "OpenSMTPD configuration found at $OPENSMTPD_CONFIG"
|
|
||||||
|
|
||||||
# Check if OpenSMTPD is already running
|
|
||||||
if [ -f "$OPENSMTPD_PID_FILE" ] && kill -0 "$(cat "$OPENSMTPD_PID_FILE")" 2>/dev/null; then
|
|
||||||
log "OpenSMTPD is already running (PID: $(cat "$OPENSMTPD_PID_FILE"))"
|
|
||||||
else
|
|
||||||
log "Starting OpenSMTPD..."
|
|
||||||
"$OPENSMTPD_BINARY" -d -f "$OPENSMTPD_CONFIG" 2>&1 &
|
|
||||||
OPENSMTPD_PID=$!
|
|
||||||
|
|
||||||
# Wait for OpenSMTPD to start
|
|
||||||
sleep 2
|
|
||||||
if kill -0 "$OPENSMTPD_PID" 2>/dev/null; then
|
|
||||||
log "OpenSMTPD started successfully (PID: $OPENSMTPD_PID)"
|
|
||||||
echo "$OPENSMTPD_PID" > "$OPENSMTPD_PID_FILE"
|
|
||||||
else
|
|
||||||
log "WARNING: OpenSMTPD failed to start"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log "OpenSMTPD not configured or binary not found, skipping SMTP setup"
|
|
||||||
if [ ! -f "$OPENSMTPD_CONFIG" ]; then
|
|
||||||
log " Config file missing: $OPENSMTPD_CONFIG"
|
|
||||||
fi
|
|
||||||
if [ -z "$OPENSMTPD_BINARY" ]; then
|
|
||||||
log " Binary not found at: $OPENSMTPD_CUSTOM_BINARY or $OPENSMTPD_SYSTEM_BINARY"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
log "Starting Shopify AI App Builder service..."
|
log "Starting Shopify AI App Builder service..."
|
||||||
|
|
||||||
# Use /opt/webchat directly as it contains the actual server.js with node_modules
|
# Use /opt/webchat directly as it contains the actual server.js with node_modules
|
||||||
@@ -373,14 +283,6 @@ cleanup() {
|
|||||||
monitor_resources
|
monitor_resources
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Stop OpenSMTPD if running
|
|
||||||
if [ -n "$OPENSMTPD_PID" ] && kill -0 "$OPENSMTPD_PID" 2>/dev/null; then
|
|
||||||
log "Terminating OpenSMTPD service (PID: $OPENSMTPD_PID)"
|
|
||||||
kill "$OPENSMTPD_PID" 2>/dev/null || true
|
|
||||||
wait "$OPENSMTPD_PID" 2>/dev/null || true
|
|
||||||
log "OpenSMTPD service terminated"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$MONITOR_PID" ] && kill -0 "$MONITOR_PID" 2>/dev/null; then
|
if [ -n "$MONITOR_PID" ] && kill -0 "$MONITOR_PID" 2>/dev/null; then
|
||||||
log "Terminating monitor process (PID: $MONITOR_PID)"
|
log "Terminating monitor process (PID: $MONITOR_PID)"
|
||||||
kill "$MONITOR_PID" 2>/dev/null || true
|
kill "$MONITOR_PID" 2>/dev/null || true
|
||||||
|
|||||||
@@ -172,61 +172,6 @@ main() {
|
|||||||
exit_code=1
|
exit_code=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check OpenSMTPD service (ports 25, 587, 465)
|
|
||||||
health_log "INFO" "=== OpenSMTPD Service ==="
|
|
||||||
REPO_DIR="${REPO_DIR:-/home/web/data}"
|
|
||||||
OPENSMTPD_INSTALL_ROOT="/workspace/src/backend/app/opensmtpd/install"
|
|
||||||
if [ -d "${REPO_DIR}/backend/app/opensmtpd" ]; then
|
|
||||||
OPENSMTPD_INSTALL_ROOT="${REPO_DIR}/backend/app/opensmtpd/install"
|
|
||||||
fi
|
|
||||||
OPENSMTPD_CUSTOM_BINARY="${OPENSMTPD_INSTALL_ROOT}/sbin/smtpd"
|
|
||||||
OPENSMTPD_SYSTEM_BINARY="/usr/sbin/smtpd"
|
|
||||||
|
|
||||||
# Determine which binary to use (prefer custom, fallback to system)
|
|
||||||
OPENSMTPD_BINARY=""
|
|
||||||
if [ -x "$OPENSMTPD_CUSTOM_BINARY" ]; then
|
|
||||||
OPENSMTPD_BINARY="$OPENSMTPD_CUSTOM_BINARY"
|
|
||||||
elif [ -x "$OPENSMTPD_SYSTEM_BINARY" ]; then
|
|
||||||
OPENSMTPD_BINARY="$OPENSMTPD_SYSTEM_BINARY"
|
|
||||||
elif command -v smtpd &>/dev/null; then
|
|
||||||
OPENSMTPD_BINARY="$(command -v smtpd)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$OPENSMTPD_BINARY" ]; then
|
|
||||||
# Check SMTP port 25
|
|
||||||
if check_port 25 "SMTP"; then
|
|
||||||
health_log "INFO" "✓ SMTP port 25 is listening"
|
|
||||||
else
|
|
||||||
health_log "WARN" "⚠ SMTP port 25 is not listening (may be normal if not using inbound email)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check SMTP submission port 587
|
|
||||||
if check_port 587 "SMTP Submission"; then
|
|
||||||
health_log "INFO" "✓ SMTP submission port 587 is listening"
|
|
||||||
else
|
|
||||||
health_log "WARN" "⚠ SMTP submission port 587 is not listening"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check SMTPS port 465
|
|
||||||
if check_port 465 "SMTPS"; then
|
|
||||||
health_log "INFO" "✓ SMTPS port 465 is listening"
|
|
||||||
else
|
|
||||||
health_log "WARN" "⚠ SMTPS port 465 is not listening"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check OpenSMTPD process
|
|
||||||
if pgrep -f "smtpd" > /dev/null; then
|
|
||||||
local smtpd_pid=$(pgrep -f "smtpd" | head -1)
|
|
||||||
health_log "INFO" "✓ OpenSMTPD process running (PID: ${smtpd_pid})"
|
|
||||||
else
|
|
||||||
health_log "WARN" "⚠ OpenSMTPD process not found (may be disabled)"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
health_log "INFO" "OpenSMTPD not installed (checked: $OPENSMTPD_CUSTOM_BINARY, $OPENSMTPD_SYSTEM_BINARY, PATH), skipping SMTP checks"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ttyd service has been removed, no longer checking port 4501
|
|
||||||
|
|
||||||
health_log "INFO" "========== HEALTH CHECK END ==========="
|
health_log "INFO" "========== HEALTH CHECK END ==========="
|
||||||
|
|
||||||
if [ $exit_code -eq 0 ]; then
|
if [ $exit_code -eq 0 ]; then
|
||||||
|
|||||||
@@ -8,10 +8,6 @@ services:
|
|||||||
# This enables reliable multi-architecture builds (amd64, arm64, etc.)
|
# This enables reliable multi-architecture builds (amd64, arm64, etc.)
|
||||||
ports:
|
ports:
|
||||||
- "4500:4500"
|
- "4500:4500"
|
||||||
# OpenSMTPD ports for email functionality
|
|
||||||
- "25:25"
|
|
||||||
- "587:587"
|
|
||||||
- "465:465"
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
- OPENCODE_API_KEY=${OPENCODE_API_KEY:-}
|
- OPENCODE_API_KEY=${OPENCODE_API_KEY:-}
|
||||||
|
|||||||
Reference in New Issue
Block a user