|
2 | 2 |
|
3 | 3 | # Set common paths
|
4 | 4 | STANDALONE_DIR="$PWD/.next/standalone"
|
5 |
| -PUBLIC_DIR="$PWD/public" |
6 | 5 | APP_DIR="$STANDALONE_DIR/apps/cache-testing"
|
| 6 | +PUBLIC_DIR="$PWD/public" |
7 | 7 | STATIC_DIR="$PWD/.next/static"
|
8 | 8 | INSTANCES_DIR="$PWD/.next/__instances"
|
9 | 9 |
|
10 |
| -# Remove existing $INSTANCES_DIR directory |
11 |
| -if ! rm -rf $INSTANCES_DIR; then |
12 |
| - echo "Failed to remove existing $INSTANCES_DIR directory" |
13 |
| - exit 1 |
14 |
| -fi |
15 |
| - |
16 |
| -# Create $INSTANCES_DIR directory |
17 |
| -if ! mkdir -p $INSTANCES_DIR/3000; then |
18 |
| - echo "Failed to create $INSTANCES_DIR/3000 directory" |
19 |
| - exit 1 |
20 |
| -fi |
21 |
| - |
22 |
| -# Create $INSTANCES_DIR directory |
23 |
| -if ! mkdir -p $INSTANCES_DIR/3001; then |
24 |
| - echo "Failed to create $INSTANCES_DIR/3001 directory" |
25 |
| - exit 1 |
26 |
| -fi |
27 |
| - |
28 |
| -# Copy files from $STANDALONE_DIR to $INSTANCES_DIR/3000 |
29 |
| -if ! cp -r $STANDALONE_DIR/. $INSTANCES_DIR/3000/; then |
30 |
| - echo "Failed to copy standalone directory" |
31 |
| - exit 1 |
32 |
| -fi |
33 |
| - |
34 |
| -# Copy $PUBLIC_DIR to $INSTANCES_DIR/3000/public |
35 |
| -if ! cp -r $PUBLIC_DIR/ $INSTANCES_DIR/3000/public/; then |
36 |
| - echo "Failed to copy public directory" |
37 |
| - exit 1 |
38 |
| -fi |
39 |
| - |
40 |
| -# Copy files from $APP_DIR to $INSTANCES_DIR/3000 |
41 |
| -if ! cp -r $STANDALONE_DIR/apps/cache-testing/. $INSTANCES_DIR/3000/; then |
42 |
| - echo "Failed to copy app directory" |
43 |
| - exit 1 |
44 |
| -fi |
45 |
| - |
46 |
| -# Copy $STATIC_DIR to $INSTANCES_DIR/3000/.next/static |
47 |
| -if ! cp -r $STATIC_DIR/ $INSTANCES_DIR/3000/.next/static/; then |
48 |
| - echo "Failed to copy static directory" |
49 |
| - exit 1 |
50 |
| -fi |
51 |
| - |
52 |
| -# Copy files from $INSTANCES_DIR/3000 to $INSTANCES_DIR/3001 |
53 |
| -if ! cp -r $INSTANCES_DIR/3000/. $INSTANCES_DIR/3001/.; then |
54 |
| - echo "Failed to copy $INSTANCES_DIR from 3000 to 3001" |
55 |
| - exit 1 |
56 |
| -fi |
| 10 | +copy_dir() { |
| 11 | + if ! cp -r "$1" "$2"; then |
| 12 | + echo "Failed to copy from $1 to $2" |
| 13 | + exit 1 |
| 14 | + fi |
| 15 | +} |
| 16 | + |
| 17 | +# Copy public directory to standalone app directory |
| 18 | +copy_dir "$PUBLIC_DIR/" "$APP_DIR/public" |
| 19 | + |
| 20 | +# Copy static directory to standalone app/.next directory |
| 21 | +copy_dir "$STATIC_DIR/" "$APP_DIR/.next/static" |
| 22 | + |
| 23 | +create_instance_dir() { |
| 24 | + if ! mkdir -p "$INSTANCES_DIR/$1"; then |
| 25 | + echo "Failed to create $INSTANCES_DIR/$1 directory" |
| 26 | + exit 1 |
| 27 | + fi |
| 28 | +} |
| 29 | + |
| 30 | +# Create instance directories |
| 31 | +create_instance_dir 3000 |
| 32 | +create_instance_dir 3001 |
| 33 | + |
| 34 | +# Copy files from standalone directory to instance directories |
| 35 | +copy_dir "$STANDALONE_DIR/." "$INSTANCES_DIR/3000" |
| 36 | +copy_dir "$STANDALONE_DIR/." "$INSTANCES_DIR/3001" |
0 commit comments