Spaces:
Sleeping
Sleeping
abubasith86
commited on
Commit
Β·
617d6a7
1
Parent(s):
8bcabf8
CHG
Browse files- Dockerfile +8 -5
- deploy.sh +5 -10
Dockerfile
CHANGED
@@ -1,17 +1,20 @@
|
|
1 |
# Use official Node.js image
|
2 |
FROM node:23.7.0
|
3 |
|
4 |
-
# Set working directory
|
5 |
-
WORKDIR /app
|
6 |
|
7 |
-
# Install
|
8 |
-
RUN apt-get update && apt-get install -y git
|
9 |
|
10 |
# Copy the deploy script
|
11 |
COPY deploy.sh /deploy.sh
|
12 |
|
13 |
-
#
|
14 |
RUN chmod +x /deploy.sh
|
15 |
|
|
|
|
|
|
|
16 |
# Run the script on container startup
|
17 |
CMD ["/deploy.sh"]
|
|
|
1 |
# Use official Node.js image
|
2 |
FROM node:23.7.0
|
3 |
|
4 |
+
# Set working directory to a writable location
|
5 |
+
WORKDIR /home/node/app
|
6 |
|
7 |
+
# Install required dependencies
|
8 |
+
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
9 |
|
10 |
# Copy the deploy script
|
11 |
COPY deploy.sh /deploy.sh
|
12 |
|
13 |
+
# Set correct permissions for the script
|
14 |
RUN chmod +x /deploy.sh
|
15 |
|
16 |
+
# Set Node.js environment
|
17 |
+
ENV NODE_ENV=production
|
18 |
+
|
19 |
# Run the script on container startup
|
20 |
CMD ["/deploy.sh"]
|
deploy.sh
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
#!/bin/bash
|
2 |
|
3 |
-
# Set
|
4 |
-
APP_DIR="/app"
|
5 |
GIT_REPO="https://github.com/abubasith456/Node-WLA.git"
|
6 |
BRANCH="main"
|
7 |
|
8 |
echo "π Deployment started..."
|
9 |
|
10 |
-
#
|
11 |
if [ -d "$APP_DIR" ]; then
|
12 |
cd "$APP_DIR"
|
13 |
|
14 |
-
# Check if it
|
15 |
if [ -d ".git" ]; then
|
16 |
echo "π Directory exists, pulling latest changes..."
|
17 |
git reset --hard
|
@@ -26,14 +26,9 @@ else
|
|
26 |
git clone -b "$BRANCH" "$GIT_REPO" "$APP_DIR"
|
27 |
fi
|
28 |
|
29 |
-
# Navigate to app directory
|
30 |
cd "$APP_DIR"
|
31 |
|
32 |
-
# Fix file permissions for Node.js
|
33 |
-
echo "π§ Fixing permissions..."
|
34 |
-
chown -R $(whoami) "$APP_DIR"
|
35 |
-
chmod -R 755 "$APP_DIR"
|
36 |
-
|
37 |
# Install dependencies
|
38 |
echo "π¦ Installing dependencies..."
|
39 |
npm install --unsafe-perm
|
|
|
1 |
#!/bin/bash
|
2 |
|
3 |
+
# Set new writable directory
|
4 |
+
APP_DIR="/home/node/app"
|
5 |
GIT_REPO="https://github.com/abubasith456/Node-WLA.git"
|
6 |
BRANCH="main"
|
7 |
|
8 |
echo "π Deployment started..."
|
9 |
|
10 |
+
# Ensure the directory exists
|
11 |
if [ -d "$APP_DIR" ]; then
|
12 |
cd "$APP_DIR"
|
13 |
|
14 |
+
# Check if it's a valid Git repository
|
15 |
if [ -d ".git" ]; then
|
16 |
echo "π Directory exists, pulling latest changes..."
|
17 |
git reset --hard
|
|
|
26 |
git clone -b "$BRANCH" "$GIT_REPO" "$APP_DIR"
|
27 |
fi
|
28 |
|
29 |
+
# Navigate to the app directory
|
30 |
cd "$APP_DIR"
|
31 |
|
|
|
|
|
|
|
|
|
|
|
32 |
# Install dependencies
|
33 |
echo "π¦ Installing dependencies..."
|
34 |
npm install --unsafe-perm
|