-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom-build.sh
executable file
·66 lines (48 loc) · 1.65 KB
/
custom-build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# build.sh
# Stop on any error
set -e
# Github Username and Repository where the container will be stored
GH_USERNAME="agriculturedev"
GH_REPO="elie-masterportal"
git clone https://bitbucket.org/geowerkstatt-hamburg/addons.git /tmp/addons
rsync -av --exclude='addonsConf.json' /tmp/addons/ addons/
npm install
cd addons
npm ci
cd ../
cd addons/dipasAddons/dataNarrator
npm install --legacy-peer-deps
cd ../../../
echo "Replacing production URL..."
node elie/devtools/tasks/replaceProductionURL.js
# Step 1: Build the npm app
echo "Building the npm app..."
npm run elie-buildPortal
# Step 2: Go to the build directory
cd dist
# Step 3: Declare an array of app names for which you want to build Docker images
apps=("mp-guben" "mobility-data")
# Step 4: Copy master code to each app directory
echo "Copying master code to app directories..."
for app in "${apps[@]}"
do
# Create the folder if it doesn't exist
mkdir -p "$app"
cp -r mastercode "$app/"
done
# Step 5: Login to GitHub Container Registry
echo "Logging into GitHub Container Registry..."
echo $GH_TOKEN | docker login ghcr.io -u $GH_USERNAME --password-stdin
# Step 6: Loop through apps, build Docker images, and push to GitHub Container Registry
for app in "${apps[@]}"
do
echo "Building Docker image for $app..."
image_name="ghcr.io/$GH_USERNAME/$GH_REPO/$app"
local_image_name="$app:local"
docker buildx build --load -t "$local_image_name" -f ../elie/docker/Dockerfile --platform linux/amd64 "$app/"
docker tag "$local_image_name" "$image_name:latest"
echo "Pushing Docker image for $app..."
docker push $image_name
done
echo "All builds are completed."