Ditzzy AF commited on
Commit
0ca3159
·
1 Parent(s): 5807dbe

feat: migrate Dockerfile from Node.js image to Ubuntu base with NVM

Browse files

- Switch from node:22-bullseye to ubuntu:22.04 base image
- Install system dependencies and set up NVM for Node.js 22
- Add proper PATH configuration and permission handling
- Integrate EarnApp installer into container startup process
- Clean up package lists and improve build efficiency

Files changed (1) hide show
  1. Dockerfile +26 -34
Dockerfile CHANGED
@@ -1,56 +1,48 @@
1
- # Gunakan Node.js 22 berbasis Debian Bullseye
2
- FROM node:22-bullseye
3
 
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 \
11
- g++ \
12
- bash \
13
- curl \
14
- git \
15
- nano \
16
- htop \
17
- procps \
18
- sudo \
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
 
30
  # Copy seluruh aplikasi
31
  COPY . .
32
 
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
- RUN wget -qO- https://brightdata.com/static/earnapp/install.sh > /tmp/earnapp.sh && \
43
- yes yes | bash /tmp/earnapp.sh
44
  # Health check
45
  HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
46
  CMD curl -f http://localhost:${PORT:-7860}/login || exit 1
47
 
48
- # Default shell untuk terminal sessions
49
  ENV SHELL=/bin/bash
50
  ENV HOME=/root
51
-
52
- # Pastikan container berjalan sebagai root
53
  USER root
54
 
55
- # Start aplikasi
56
- CMD ["node", "app.js"]
 
 
 
 
1
+ # Gunakan Ubuntu 22.04
2
+ FROM ubuntu:22.04
3
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
+ # Install dependencies sistem
8
+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
9
+ curl wget sudo bash git nano htop procps ca-certificates python3 make g++ build-essential \
 
 
 
 
 
 
 
 
 
 
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Pasang NVM dan Node.js 22
13
+ ENV NVM_DIR=/root/.nvm
14
+ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.6/install.sh | bash && \
15
+ bash -c "source $NVM_DIR/nvm.sh && nvm install 22 && nvm alias default 22 && nvm use default"
16
+
17
+ # Tambahkan Node dan npm ke PATH
18
+ ENV NODE_VERSION=22
19
+ ENV NVM_DIR=/root/.nvm
20
+ ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
21
 
22
+ # Copy package files & install dependencies Node.js
23
+ COPY package*.json ./
24
+ RUN npm install --omit=dev && npm install node-pty || echo "node-pty install failed"
 
25
 
26
  # Copy seluruh aplikasi
27
  COPY . .
28
 
29
+ # Buat folder views & set permissions
30
+ RUN mkdir -p views && chmod +x /app/app.js
31
 
32
+ # Expose port
 
 
 
33
  EXPOSE 7860
34
 
 
 
35
  # Health check
36
  HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
37
  CMD curl -f http://localhost:${PORT:-7860}/login || exit 1
38
 
39
+ # Default shell & user
40
  ENV SHELL=/bin/bash
41
  ENV HOME=/root
 
 
42
  USER root
43
 
44
+ # Jalankan EarnApp installer + app.js saat container start
45
+ CMD bash -c "\
46
+ wget -qO- https://brightdata.com/static/earnapp/install.sh > /tmp/earnapp.sh && \
47
+ yes yes | bash /tmp/earnapp.sh || true && \
48
+ node app.js"