Skip to content

Commit 99fbe8f

Browse files
Merge pull request #816 from contentstack/fix/CMG-757
refactor: update docker-compose configuration for improved environmen…
2 parents 27dbbb3 + deaaafc commit 99fbe8f

19 files changed

+205
-65
lines changed

api/src/config/dev.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ export const devConfig = {
44
EU: "https://stag-eu-api.csnonprod.com/v3",
55
AZURE_NA: "https://stag-azure-na-api.csnonprod.com/v3",
66
GCP_NA: "https://stag-gcp-na-api.csnonprod.com/v3",
7+
AU:"https://stag-au-api.csnonprod.com/v3",
8+
GCP_EU: "https://stag-gcp-eu-api.csnonprod.com/v3",
79
},
810
CS_URL: {
911
NA: "https://app.contentstack.com/#!",
1012
EU: "https://eu-app.contentstack.com/#!",
1113
AZURE_NA: "https://azure-na-app.contentstack.com/#!",
1214
AZURE_EU: "https://azure-eu-app.contentstack.com/#!",
1315
GCP_NA: "https://gcp-na-app.contentstack.com/#!",
16+
AU: "https://au-app.contentstack.com/#!",
17+
GCP_EU: "https://gcp-eu-app.contentstack.com/#!",
1418
},
1519
LOG_FILE_PATH:
1620
process.platform === "win32" ? ".\\combine.log" : "./combine.log", // Replace with the actual path to your log file

api/src/config/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@ export type ConfigType = {
2727
AZURE_NA: string;
2828
AZURE_EU?: string;
2929
GCP_NA?: string;
30+
AU?: string;
31+
GCP_EU?: string;
3032
};
3133
CS_URL: {
3234
NA: string;
3335
EU: string;
3436
AZURE_NA: string;
3537
AZURE_EU?: string;
3638
GCP_NA?: string;
39+
AU?: string;
40+
GCP_EU?: string;
3741
};
3842
LOG_FILE_PATH: string;
3943
};

api/src/config/prod.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ export const prodConfig = {
55
AZURE_NA: "https://azure-na-api.contentstack.com/v3",
66
AZURE_EU: "https://azure-eu-api.contentstack.com/v3",
77
GCP_NA: "https://gcp-na-api.contentstack.com/v3",
8+
AU: "https://au-api.contentstack.com/v3",
9+
GCP_EU: "https://gcp-eu-api.contentstack.com/v3",
810
},
911
CS_URL: {
1012
NA: "https://app.contentstack.com/#!",
1113
EU: "https://eu-app.contentstack.com/#!",
1214
AZURE_NA: "https://azure-na-app.contentstack.com/#!",
1315
AZURE_EU: "https://azure-eu-app.contentstack.com/#!",
1416
GCP_NA: "https://gcp-na-app.contentstack.com/#!",
17+
AU: "https://au-app.contentstack.com/#!",
18+
GCP_EU: "https://gcp-eu-app.contentstack.com/#!",
1519
},
1620
LOG_FILE_PATH:
1721
process.platform === "win32" ? ".\\sample.log" : "./sample.log", // Replace with the actual path to your log file

api/src/constants/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
export const CS_REGIONS = ["NA", "EU", "AZURE_NA", "AZURE_EU", "GCP_NA"];
1+
export const CS_REGIONS = ["NA", "EU", "AZURE_NA", "AZURE_EU", "GCP_NA", "AU", "GCP_EU"];
22
export const DEVURLS: any = {
33
NA: "developerhub-api.contentstack.com",
44
EU: "eu-developerhub-api.contentstack.com",
55
AZURE_NA: "azure-na-developerhub-api.contentstack.com",
66
AZURE_EU: "azure-eu-developerhub-api.contentstack.com",
77
GCP_NA: "gcp-na-developerhub-api.contentstack.com",
8+
AU: "au-developerhub-api.contentstack.com",
9+
GCP_EU: "gcp-eu-developerhub-api.contentstack.com",
810
};
911
export const CMS = {
1012
CONTENTFUL: "contentful",

api/src/services/aem.service.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,21 @@ function processFieldsRecursive(
708708
obj[uid] = jsonData;
709709
break;
710710
}
711+
case 'html': {
712+
const aemFieldName = field?.otherCmsField ? getLastKey(field?.otherCmsField, ' > ') : field?.uid;
713+
const value = getFieldValue(items, aemFieldName);
714+
const uid = getLastKey(field?.contentstackFieldUid);
715+
716+
let htmlContent = '';
717+
718+
if (typeof value === 'string') {
719+
htmlContent = value;
720+
} else if (value && typeof value === 'object') {
721+
htmlContent = value?.text || value?.content || '';
722+
}
723+
obj[uid] = htmlContent;
724+
break;
725+
}
711726
case 'link': {
712727
const value = {
713728
title: getFieldValue(items, 'title') ?? '',

docker-compose.yml

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
version: "3.8"
2+
23
services:
34
api:
45
container_name: migration-api
56
build:
67
context: ./api
78
ports:
89
- "5001:5001"
9-
restart: always
10+
restart: unless-stopped
1011
volumes:
11-
- ${CMS_DATA_PATH}:${CONTAINER_PATH}
12+
- ${DOCKER_MOUNT_PATH:-${CMS_DATA_PATH}}:${CONTAINER_PATH}:ro
1213
- shared_data:/app/extracted_files
14+
environment:
15+
- NODE_ENV=${NODE_ENV:-production}
16+
- CMS_TYPE=${CMS_TYPE}
17+
- CONTAINER_PATH=${CONTAINER_PATH}
18+
- CMS_DATA_PATH=${CMS_DATA_PATH}
19+
- AEM_TEMPLATES_DIR=${AEM_TEMPLATES_DIR:-templates}
20+
networks:
21+
- migration-network
1322
security_opt:
1423
- no-new-privileges:true
1524

@@ -19,22 +28,47 @@ services:
1928
context: ./upload-api
2029
ports:
2130
- "4002:4002"
22-
restart: always
31+
restart: unless-stopped
2332
volumes:
24-
- ${CMS_DATA_PATH}:${CONTAINER_PATH}
33+
- ${DOCKER_MOUNT_PATH:-${CMS_DATA_PATH}}:${CONTAINER_PATH}:ro
2534
- shared_data:/app/extracted_files
35+
environment:
36+
- NODE_ENV=${NODE_ENV:-production}
37+
- CMS_TYPE=${CMS_TYPE}
38+
- CONTAINER_PATH=${CONTAINER_PATH}
39+
- CMS_DATA_PATH=${CMS_DATA_PATH}
40+
- NODE_BACKEND_API=${NODE_BACKEND_API:-http://migration-api:5001}
41+
- AEM_TEMPLATES_DIR=${AEM_TEMPLATES_DIR:-templates}
42+
networks:
43+
- migration-network
2644
security_opt:
2745
- no-new-privileges:true
46+
depends_on:
47+
- api
2848

2949
ui:
3050
container_name: migration-ui
3151
build:
3252
context: ./ui
3353
ports:
3454
- "3000:3000"
35-
restart: always
55+
restart: unless-stopped
56+
environment:
57+
- NODE_ENV=${NODE_ENV:-production}
58+
- REACT_APP_API_URL=${REACT_APP_API_URL:-http://localhost:5001}
59+
- REACT_APP_UPLOAD_API_URL=${REACT_APP_UPLOAD_API_URL:-http://localhost:4002}
60+
networks:
61+
- migration-network
3662
security_opt:
3763
- no-new-privileges:true
64+
depends_on:
65+
- api
66+
- upload-api
67+
68+
networks:
69+
migration-network:
70+
driver: bridge
3871

3972
volumes:
4073
shared_data:
74+
driver: local

setup-docker.sh

Lines changed: 98 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
echo "Choose the CMS (numbers):"
4-
select CMS_TYPE in "sitecore" "contentful" "wordpress"; do
4+
select CMS_TYPE in "sitecore" "contentful" "wordpress" "aem"; do
55
case $CMS_TYPE in
66
sitecore)
77
EXAMPLE_FILE="sitecore.zip"
@@ -15,20 +15,26 @@ select CMS_TYPE in "sitecore" "contentful" "wordpress"; do
1515
EXAMPLE_FILE="wordpress.xml"
1616
break
1717
;;
18+
aem)
19+
EXAMPLE_FILE="aem_data_structure"
20+
break
21+
;;
1822
*)
19-
echo "Invalid option. Please select 1, 2, or 3."
23+
echo "Invalid option. Please select 1, 2, 3, or 4."
2024
;;
2125
esac
2226
done
2327

24-
read -p "Enter the full path to your $CMS_TYPE data file (e.g., $EXAMPLE_FILE): " CMS_DATA_PATH
25-
26-
# Remove surrounding quotes if they exist
27-
CMS_DATA_PATH="${CMS_DATA_PATH%\"}"
28-
CMS_DATA_PATH="${CMS_DATA_PATH#\"}"
28+
# Prompt for the CMS data path
29+
echo "Enter the path to your $CMS_TYPE data:"
30+
if [[ "$CMS_TYPE" == "aem" ]]; then
31+
echo "(Path should contain a 'templates' folder with JSON files, or provide direct path to templates folder)"
32+
fi
33+
read -r CMS_DATA_PATH
2934

30-
# Store original Windows path for Docker volume mounting
35+
# Store original path for Docker (Windows paths work with Docker Desktop)
3136
ORIGINAL_PATH="$CMS_DATA_PATH"
37+
DOCKER_MOUNT_PATH="$CMS_DATA_PATH" # Path to mount in Docker
3238

3339
# Convert Windows path to Unix format for Git Bash file operations ONLY
3440
UNIX_PATH="$CMS_DATA_PATH"
@@ -39,15 +45,60 @@ if [[ "$CMS_DATA_PATH" =~ ^[A-Za-z]:\\ ]]; then
3945
UNIX_PATH=$(echo "$UNIX_PATH" | sed 's/^\([A-Za-z]\):/\/\L\1/')
4046
fi
4147

42-
# Check if file exists using the converted path
43-
if [ ! -f "$UNIX_PATH" ]; then
44-
echo "❌ File does not exist: $UNIX_PATH"
45-
exit 1
48+
# Check if file/directory exists using the converted path
49+
if [[ "$CMS_TYPE" == "aem" ]]; then
50+
# For AEM, check if it's a directory
51+
if [ ! -d "$UNIX_PATH" ]; then
52+
echo "❌ Directory does not exist: $UNIX_PATH"
53+
echo "Please provide the path to your AEM data structure folder"
54+
exit 1
55+
fi
56+
57+
# Check if the provided path IS the templates folder
58+
if [[ "$(basename "$UNIX_PATH")" == "templates" ]]; then
59+
# User provided the templates folder directly
60+
TEMPLATES_PATH="$UNIX_PATH"
61+
# Get parent directory for Docker mounting
62+
UNIX_MOUNT_PATH="$(dirname "$UNIX_PATH")"
63+
DOCKER_MOUNT_PATH="$(dirname "$ORIGINAL_PATH")"
64+
echo "ℹ️ Detected direct templates path, using parent folder for Docker mounting"
65+
else
66+
# User provided the parent folder
67+
TEMPLATES_PATH="$UNIX_PATH/templates"
68+
UNIX_MOUNT_PATH="$UNIX_PATH"
69+
70+
# Verify templates folder exists
71+
if [ ! -d "$TEMPLATES_PATH" ]; then
72+
echo "❌ 'templates' folder not found in: $UNIX_PATH"
73+
echo "Expected structure: your-folder/templates/*.json"
74+
echo "Or provide the direct path to the templates folder"
75+
exit 1
76+
fi
77+
fi
78+
79+
# Check if templates folder contains JSON files
80+
JSON_COUNT=$(find "$TEMPLATES_PATH" -maxdepth 1 -name "*.json" -type f 2>/dev/null | wc -l)
81+
if [ "$JSON_COUNT" -eq 0 ]; then
82+
echo "❌ No JSON files found in templates folder: $TEMPLATES_PATH"
83+
echo "Please ensure your templates folder contains template JSON files"
84+
exit 1
85+
fi
86+
87+
echo "✅ Found $JSON_COUNT JSON template file(s) in templates folder"
88+
89+
FILENAME=$(basename "$UNIX_MOUNT_PATH")
90+
CONTAINER_PATH="/data/$FILENAME"
91+
else
92+
# For other CMS types, check if it's a file
93+
if [ ! -f "$UNIX_PATH" ]; then
94+
echo "❌ File does not exist: $UNIX_PATH"
95+
exit 1
96+
fi
97+
98+
FILENAME=$(basename "$UNIX_PATH")
99+
CONTAINER_PATH="/data/$FILENAME"
46100
fi
47101

48-
FILENAME=$(basename "$UNIX_PATH")
49-
CONTAINER_PATH="/data/$FILENAME"
50-
51102
export CMS_TYPE
52103
export CMS_DATA_PATH="$ORIGINAL_PATH"
53104
export CONTAINER_PATH
@@ -73,11 +124,19 @@ set_env_var() {
73124
}
74125

75126
set_env_var "CMS_TYPE" "$CMS_TYPE"
76-
# Use original Windows path for Docker volume mounting
127+
# Save the full path to templates (what user provided)
77128
set_env_var "CMS_DATA_PATH" "$ORIGINAL_PATH"
129+
# Save the Docker mount path (may be parent directory for AEM)
130+
set_env_var "DOCKER_MOUNT_PATH" "$DOCKER_MOUNT_PATH"
78131
set_env_var "CONTAINER_PATH" "$CONTAINER_PATH"
79132
set_env_var "NODE_BACKEND_API" "http://migration-api:5001"
80133

134+
# Set AEM-specific environment variables
135+
if [[ "$CMS_TYPE" == "aem" ]]; then
136+
set_env_var "AEM_TEMPLATES_DIR" "templates"
137+
echo "ℹ️ Set AEM_TEMPLATES_DIR to: templates"
138+
fi
139+
81140
# Check if docker-compose.yml exists before running
82141
if [ ! -f "docker-compose.yml" ]; then
83142
echo "❌ docker-compose.yml not found in current directory"
@@ -87,10 +146,30 @@ if [ ! -f "docker-compose.yml" ]; then
87146
exit 1
88147
fi
89148

149+
# Check if Docker is running
150+
if ! docker info > /dev/null 2>&1; then
151+
echo ""
152+
echo "❌ Docker is not running!"
153+
echo "Please start Docker Desktop and try again."
154+
exit 1
155+
fi
156+
157+
echo ""
90158
echo "✅ Starting Docker Compose with the following configuration:"
159+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
91160
echo "CMS_TYPE: $CMS_TYPE"
92-
echo "CMS_DATA_PATH (for Docker): $ORIGINAL_PATH"
93-
echo "CMS_DATA_PATH (for file check): $UNIX_PATH"
94-
echo "CONTAINER_PATH: $CONTAINER_PATH"
161+
echo "CMS_DATA_PATH: $ORIGINAL_PATH"
162+
if [[ "$CMS_TYPE" == "aem" ]]; then
163+
echo "DOCKER_MOUNT_PATH: $DOCKER_MOUNT_PATH"
164+
echo "CONTAINER_PATH: $CONTAINER_PATH"
165+
echo "Templates accessible at: $CONTAINER_PATH/templates"
166+
else
167+
echo "CONTAINER_PATH: $CONTAINER_PATH"
168+
fi
169+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
170+
echo ""
171+
172+
# Export for docker-compose
173+
export DOCKER_MOUNT_PATH
95174

96175
MSYS_NO_PATHCONV=1 docker compose up --build

upload-api/migration-aem/libs/contentType/components/BreadcrumbComponent.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ export class BreadcrumbComponent extends ContentstackComponent {
2929
uid: key,
3030
displayName: key,
3131
description: "",
32-
defaultValue: schemaProp.value
32+
defaultValue: ""
3333
}).toContentstack(),
3434
boolean: (key, schemaProp) => new BooleanField({
3535
uid: key,
3636
displayName: key,
3737
description: "",
38-
defaultValue: schemaProp.value
38+
defaultValue: false
3939
}).toContentstack(),
4040
object: (key, schemaProp) => {
4141
// For breadcrumb, handle the link object
@@ -44,7 +44,7 @@ export class BreadcrumbComponent extends ContentstackComponent {
4444
uid: key,
4545
displayName: key,
4646
description: "",
47-
defaultValue: schemaProp?.properties?.url?.value
47+
defaultValue: ""
4848
}).toContentstack();
4949
}
5050
return null;

upload-api/migration-aem/libs/contentType/components/ButtonComponent.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ export class ButtonComponent extends ContentstackComponent {
5151
uid: key,
5252
displayName: key,
5353
description: "",
54-
defaultValue: schemaProp.value
54+
defaultValue: false
5555
}).toContentstack(),
5656
integer: (key, schemaProp) => new TextField({
5757
uid: key,
5858
displayName: key,
5959
description: "",
6060
isNumber: true,
61-
defaultValue: schemaProp.value
61+
defaultValue: ""
6262
}).toContentstack(),
6363
object: (key, schemaProp) => {
6464
const urlValue = schemaProp?.properties?.url?.value;
@@ -67,7 +67,7 @@ export class ButtonComponent extends ContentstackComponent {
6767
uid: key,
6868
displayName: key,
6969
description: "",
70-
defaultValue: urlValue
70+
defaultValue: ""
7171
}).toContentstack();
7272
}
7373
return null;

0 commit comments

Comments
 (0)