Ditzzy AF commited on
Commit
ad126ea
·
1 Parent(s): 056d297

fix: Update Dockerfile to improve dependency management and health check

Browse files

- Simplified system dependencies installation for node-pty
- Updated Node.js dependencies installation to omit dev dependencies
- Removed default .env file creation
- Adjusted health check to use dynamic port mapping
- Updated application start command to use port from Hugging Face Secret if available

Files changed (2) hide show
  1. .gitignore +2 -0
  2. Dockerfile +8 -13
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .env
2
+ passgen.js
Dockerfile CHANGED
@@ -4,7 +4,7 @@ FROM node:22-bullseye
4
  # Set working directory
5
  WORKDIR /app
6
 
7
- # Install dependencies sistem yang dibutuhkan untuk node-pty dan alat dasar
8
  RUN apt-get update && apt-get install -y --no-install-recommends \
9
  python3 \
10
  make \
@@ -19,11 +19,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
19
  ca-certificates \
20
  && rm -rf /var/lib/apt/lists/*
21
 
22
- # Copy package files untuk caching layer Docker
23
  COPY package*.json ./
24
 
25
- # Install Node.js dependencies, termasuk node-pty
26
- RUN npm ci --only=production && \
27
  npm install node-pty || echo "node-pty installation failed, fallback enabled" && \
28
  npm cache clean --force
29
 
@@ -33,24 +33,19 @@ COPY . .
33
  # Buat folder views
34
  RUN mkdir -p views
35
 
36
- # Set permissions (optional karena root user)
37
  RUN chmod +x /app/app.js
38
 
39
- # Buat file .env default
40
- RUN echo "PORT=7860" > /app/.env.default && \
41
- echo "NODE_ENV=production" >> /app/.env.default && \
42
- echo "SESSION_SECRET=default-secret-please-change" >> /app/.env.default
43
-
44
- # Expose port
45
  EXPOSE 7860
46
 
47
  # Health check
48
  HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
49
- CMD curl -f http://localhost:7860/login || exit 1
50
 
51
  # Default shell untuk terminal sessions
52
  ENV SHELL=/bin/bash
53
  ENV HOME=/root
54
 
55
- # Start aplikasi
56
  CMD ["node", "app.js"]
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
+ # Install dependencies sistem yang dibutuhkan untuk node-pty
8
  RUN apt-get update && apt-get install -y --no-install-recommends \
9
  python3 \
10
  make \
 
19
  ca-certificates \
20
  && rm -rf /var/lib/apt/lists/*
21
 
22
+ # Copy package files
23
  COPY package*.json ./
24
 
25
+ # Install Node.js dependencies
26
+ RUN npm install --omit=dev && \
27
  npm install node-pty || echo "node-pty installation failed, fallback enabled" && \
28
  npm cache clean --force
29
 
 
33
  # Buat folder views
34
  RUN mkdir -p views
35
 
36
+ # Set permissions (optional karena root)
37
  RUN chmod +x /app/app.js
38
 
39
+ # Expose port (Spaces biasanya override PORT lewat env)
 
 
 
 
 
40
  EXPOSE 7860
41
 
42
  # Health check
43
  HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
44
+ CMD curl -f http://localhost:${PORT:-7860}/login || exit 1
45
 
46
  # Default shell untuk terminal sessions
47
  ENV SHELL=/bin/bash
48
  ENV HOME=/root
49
 
50
+ # Start aplikasi, gunakan port dari Hugging Face Secret jika ada
51
  CMD ["node", "app.js"]