| FROM node:24-alpine |
|
|
| ############################################################################### |
| # 1. Install only necessary packages |
| ############################################################################### |
| RUN apk add --no-cache \ |
| git \ |
| bash \ |
| build-base \ |
| curl \ |
| wget \ |
| unzip \ |
| ca-certificates |
|
|
| ############################################################################### |
| # 2. Startup script (clone repo at run-time) |
| ############################################################################### |
| COPY <<'start.sh' /usr/local/bin/start.sh |
| #!/usr/bin/env bash |
| set -e |
|
|
| echo "Cloning $REPO …" |
| git clone --depth 1 "$REPO" /tmp/app |
| cd /tmp/app |
|
|
| # Install dependencies without devDependencies |
| npm install --omit=dev |
|
|
| chmod -R 777 /tmp/app |
|
|
| exec npm start |
| start.sh |
| RUN chmod +x /usr/local/bin/start.sh |
|
|
| ############################################################################### |
| # 3. Container metadata |
| ############################################################################### |
| EXPOSE 7860 |
| CMD ["/usr/local/bin/start.sh"] |