-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (55 loc) · 1.84 KB
/
Copy pathDockerfile
File metadata and controls
69 lines (55 loc) · 1.84 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
FROM node:22.14.0-bookworm-slim
# 1. Install system dependencies
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
ffmpeg \
fontconfig \
fonts-dejavu-core \
fonts-freefont-ttf \
fonts-noto-core \
bash \
openssh-server \
git \
lsof \
ca-certificates; \
rm -rf /var/lib/apt/lists/*
# 2. Configure SSH for public-key auth only
RUN set -eux; \
mkdir -p /var/run/sshd /root/.ssh; \
chmod 700 /root/.ssh; \
sed -ri 's/^#?PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config; \
sed -ri 's/^#?PubkeyAuthentication.*/PubkeyAuthentication yes/' /etc/ssh/sshd_config; \
sed -ri 's/^#?PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config; \
if ! grep -q '^AuthorizedKeysFile' /etc/ssh/sshd_config; then \
echo 'AuthorizedKeysFile .ssh/authorized_keys' >> /etc/ssh/sshd_config; \
fi
# 3. App directory
WORKDIR /app/nanopi2-dashboard
# 4. Install Node dependencies
COPY package*.json ./
RUN npm ci --omit=dev
# 5. Copy app source
COPY . .
# 6. Entrypoint script
RUN cat > /entrypoint.sh <<'SH' && chmod +x /entrypoint.sh
#!/bin/sh
set -eu
# Create runtime dir and host keys if needed
mkdir -p /run/sshd
if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
ssh-keygen -A
fi
# Start SSH daemon in background
/usr/sbin/sshd
# Disable core dumps to avoid large crash files
ulimit -c 0 || true
cd /app/nanopi2-dashboard
chmod +x /app/nanopi2-dashboard/start-server.sh
# Run app as PID 1 for proper signal handling
exec /app/nanopi2-dashboard/start-server.sh
SH
EXPOSE 22 8090
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD node -e "require('http').get('http://127.0.0.1:8090/health/ready', r => process.exit(r.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))"
ENTRYPOINT ["/entrypoint.sh"]