|
@@ -131,9 +131,32 @@ parts:
|
|
|
stage-packages:
|
|
stage-packages:
|
|
|
- libfontconfig1
|
|
- libfontconfig1
|
|
|
override-build: |
|
|
override-build: |
|
|
|
- echo "Cleaning environment first"
|
|
|
|
|
|
|
+ set -euo pipefail
|
|
|
|
|
+ echo "Cleaning environment first"
|
|
|
#rm -rf ~/.meteor ~/.npm /usr/local/lib/node_modules
|
|
#rm -rf ~/.meteor ~/.npm /usr/local/lib/node_modules
|
|
|
rm -rf .build
|
|
rm -rf .build
|
|
|
|
|
+ # Helper: resilient downloader (tries curl, then wget) with retries/backoff
|
|
|
|
|
+ download() {
|
|
|
|
|
+ url="$1"; out="$2"; attempts="${3:-5}"; sleepsec=5
|
|
|
|
|
+ for i in $(seq 1 "$attempts"); do
|
|
|
|
|
+ echo "[download] ($i/$attempts) $url -> $out"
|
|
|
|
|
+ if command -v curl >/dev/null 2>&1; then
|
|
|
|
|
+ if curl -fL --retry 5 --retry-all-errors --connect-timeout 20 --max-time 0 -o "$out" "$url"; then
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ if command -v wget >/dev/null 2>&1; then
|
|
|
|
|
+ if wget --tries=5 --waitretry=5 --retry-connrefused -O "$out" "$url"; then
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ echo "[download] attempt $i failed, sleeping ${sleepsec}s before retry..."
|
|
|
|
|
+ sleep "$sleepsec" || true
|
|
|
|
|
+ sleepsec=$(( sleepsec * 2 ))
|
|
|
|
|
+ done
|
|
|
|
|
+ echo "[download] ERROR: Unable to download $url after $attempts attempts" >&2
|
|
|
|
|
+ return 1
|
|
|
|
|
+ }
|
|
|
#echo "Using http npm packages so speedup install process https://stackoverflow.com/questions/39760113/callback-called-more-than-once-while-running-npm-install"
|
|
#echo "Using http npm packages so speedup install process https://stackoverflow.com/questions/39760113/callback-called-more-than-once-while-running-npm-install"
|
|
|
#echo "registry=http://registry.npmjs.org/" > ~/.npmrc
|
|
#echo "registry=http://registry.npmjs.org/" > ~/.npmrc
|
|
|
#echo "Installing npm, node-gyp, node-pre-gyp, fibers"
|
|
#echo "Installing npm, node-gyp, node-pre-gyp, fibers"
|
|
@@ -166,9 +189,9 @@ parts:
|
|
|
# Cleanup
|
|
# Cleanup
|
|
|
mkdir .build
|
|
mkdir .build
|
|
|
cd .build
|
|
cd .build
|
|
|
- wget https://github.com/wekan/wekan/releases/download/v8.15/wekan-8.15-amd64.zip
|
|
|
|
|
- unzip wekan-8.15-amd64.zip
|
|
|
|
|
- rm wekan-8.15-amd64.zip
|
|
|
|
|
|
|
+ download https://github.com/wekan/wekan/releases/download/v8.15/wekan-8.15-amd64.zip wekan-8.15-amd64.zip 6
|
|
|
|
|
+ unzip -q wekan-8.15-amd64.zip
|
|
|
|
|
+ rm -f wekan-8.15-amd64.zip
|
|
|
cd ..
|
|
cd ..
|
|
|
##cd .build/bundle
|
|
##cd .build/bundle
|
|
|
##find . -type d -name '*-garbage*' | xargs rm -rf
|
|
##find . -type d -name '*-garbage*' | xargs rm -rf
|
|
@@ -183,9 +206,9 @@ parts:
|
|
|
#rm fibers-multi.7z
|
|
#rm fibers-multi.7z
|
|
|
#cd ../../../../../../..
|
|
#cd ../../../../../../..
|
|
|
# Copy to Snap
|
|
# Copy to Snap
|
|
|
- wget https://github.com/wekan/node-v14-esm/releases/download/v14.21.4/node-v14.21.4-linux-x64.tar.xz
|
|
|
|
|
|
|
+ download https://github.com/wekan/node-v14-esm/releases/download/v14.21.4/node-v14.21.4-linux-x64.tar.xz node-v14.21.4-linux-x64.tar.xz 6
|
|
|
tar -xf node-v14.21.4-linux-x64.tar.xz node-v14.21.4-linux-x64/bin/node
|
|
tar -xf node-v14.21.4-linux-x64.tar.xz node-v14.21.4-linux-x64/bin/node
|
|
|
- rm node-v14.21.4-linux-x64.tar.xz
|
|
|
|
|
|
|
+ rm -f node-v14.21.4-linux-x64.tar.xz
|
|
|
mkdir $SNAPCRAFT_PART_INSTALL/bin
|
|
mkdir $SNAPCRAFT_PART_INSTALL/bin
|
|
|
cp -p node-v14.21.4-linux-x64/bin/node $SNAPCRAFT_PART_INSTALL/bin/
|
|
cp -p node-v14.21.4-linux-x64/bin/node $SNAPCRAFT_PART_INSTALL/bin/
|
|
|
rm -rf node-v14.21.4-linux-x64
|
|
rm -rf node-v14.21.4-linux-x64
|
|
@@ -226,40 +249,55 @@ parts:
|
|
|
- gnupg
|
|
- gnupg
|
|
|
- curl
|
|
- curl
|
|
|
override-build: |
|
|
override-build: |
|
|
|
- # Add Caddy repository
|
|
|
|
|
- echo "Installing Caddy 2 from the official repository..."
|
|
|
|
|
- curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /tmp/caddy-stable-archive-keyring.gpg
|
|
|
|
|
- mkdir -p /etc/apt/keyrings
|
|
|
|
|
- cp /tmp/caddy-stable-archive-keyring.gpg /etc/apt/keyrings/
|
|
|
|
|
- echo "deb [signed-by=/etc/apt/keyrings/caddy-stable-archive-keyring.gpg] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" > /etc/apt/sources.list.d/caddy-stable.list
|
|
|
|
|
- apt update
|
|
|
|
|
- apt -y install caddy
|
|
|
|
|
|
|
+ set -euo pipefail
|
|
|
|
|
+ # Resilient install of Caddy: try APT with retries, fallback to static binary
|
|
|
|
|
+ echo "Installing Caddy 2..."
|
|
|
|
|
+ try_apt_install() {
|
|
|
|
|
+ echo "[caddy] Adding repository and installing via APT"
|
|
|
|
|
+ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /tmp/caddy-stable-archive-keyring.gpg
|
|
|
|
|
+ mkdir -p /etc/apt/keyrings
|
|
|
|
|
+ cp /tmp/caddy-stable-archive-keyring.gpg /etc/apt/keyrings/
|
|
|
|
|
+ echo "deb [signed-by=/etc/apt/keyrings/caddy-stable-archive-keyring.gpg] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" > /etc/apt/sources.list.d/caddy-stable.list
|
|
|
|
|
+ apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30 update
|
|
|
|
|
+ DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30 -y install caddy
|
|
|
|
|
+ }
|
|
|
|
|
+ download_caddy_static() {
|
|
|
|
|
+ echo "[caddy] Falling back to static binary download"
|
|
|
|
|
+ CADDY_URL="https://github.com/caddyserver/caddy/releases/download/v2.8.4/caddy_2.8.4_linux_amd64.tar.gz"
|
|
|
|
|
+ TMPDIR=$(mktemp -d)
|
|
|
|
|
+ curl -fL --retry 5 --retry-all-errors --connect-timeout 20 --max-time 0 "$CADDY_URL" -o "$TMPDIR/caddy.tgz" || wget --tries=5 --waitretry=5 --retry-connrefused -O "$TMPDIR/caddy.tgz" "$CADDY_URL"
|
|
|
|
|
+ tar -C "$TMPDIR" -xzf "$TMPDIR/caddy.tgz" caddy
|
|
|
|
|
+ install -m 0755 "$TMPDIR/caddy" /usr/bin/caddy
|
|
|
|
|
+ rm -rf "$TMPDIR"
|
|
|
|
|
+ }
|
|
|
|
|
+ if ! try_apt_install; then
|
|
|
|
|
+ echo "[caddy] APT path failed; using static binary"
|
|
|
|
|
+ download_caddy_static
|
|
|
|
|
+ fi
|
|
|
|
|
|
|
|
- # Display installed Caddy version for confirmation
|
|
|
|
|
- echo "Installed Caddy version:"
|
|
|
|
|
- /usr/bin/caddy version
|
|
|
|
|
|
|
+ echo "Installed Caddy version:"
|
|
|
|
|
+ /usr/bin/caddy version || true
|
|
|
|
|
|
|
|
- # Create directory structure in the snap
|
|
|
|
|
- mkdir -p $SNAPCRAFT_PART_INSTALL/bin
|
|
|
|
|
|
|
+ # Create directory structure in the snap
|
|
|
|
|
+ mkdir -p $SNAPCRAFT_PART_INSTALL/bin
|
|
|
|
|
+ # Copy Caddy binary
|
|
|
|
|
+ cp /usr/bin/caddy $SNAPCRAFT_PART_INSTALL/bin/
|
|
|
|
|
+ chmod +x $SNAPCRAFT_PART_INSTALL/bin/caddy
|
|
|
|
|
|
|
|
- # Copy Caddy binary
|
|
|
|
|
- cp /usr/bin/caddy $SNAPCRAFT_PART_INSTALL/bin/
|
|
|
|
|
- chmod +x $SNAPCRAFT_PART_INSTALL/bin/caddy
|
|
|
|
|
|
|
+ # Create license files manually since they don't exist in the package
|
|
|
|
|
+ mkdir -p $SNAPCRAFT_PART_INSTALL/license
|
|
|
|
|
+ echo "Caddy is licensed under the Apache License 2.0. See https://github.com/caddyserver/caddy/blob/master/LICENSE" > $SNAPCRAFT_PART_INSTALL/license/CADDY_LICENSE
|
|
|
|
|
|
|
|
- # Create license files manually since they don't exist in the package
|
|
|
|
|
- mkdir -p $SNAPCRAFT_PART_INSTALL/license
|
|
|
|
|
- echo "Caddy is licensed under the Apache License 2.0. See https://github.com/caddyserver/caddy/blob/master/LICENSE" > $SNAPCRAFT_PART_INSTALL/license/CADDY_LICENSE
|
|
|
|
|
|
|
+ # Create a basic default Caddyfile for the snap
|
|
|
|
|
+ mkdir -p $SNAPCRAFT_PART_INSTALL/etc
|
|
|
|
|
+ cat > $SNAPCRAFT_PART_INSTALL/etc/Caddyfile << 'EOF'
|
|
|
|
|
+ # Default Caddyfile for Wekan
|
|
|
|
|
+ # This is loaded by caddy-control script if no other config is provided
|
|
|
|
|
|
|
|
- # Create a basic default Caddyfile for the snap
|
|
|
|
|
- mkdir -p $SNAPCRAFT_PART_INSTALL/etc
|
|
|
|
|
- cat > $SNAPCRAFT_PART_INSTALL/etc/Caddyfile << 'EOF'
|
|
|
|
|
- # Default Caddyfile for Wekan
|
|
|
|
|
- # This is loaded by caddy-control script if no other config is provided
|
|
|
|
|
-
|
|
|
|
|
- :8080 {
|
|
|
|
|
- reverse_proxy localhost:3000
|
|
|
|
|
- }
|
|
|
|
|
- EOF
|
|
|
|
|
|
|
+ :8080 {
|
|
|
|
|
+ reverse_proxy localhost:3000
|
|
|
|
|
+ }
|
|
|
|
|
+ EOF
|
|
|
stage:
|
|
stage:
|
|
|
- bin/caddy
|
|
- bin/caddy
|
|
|
- license/CADDY_LICENSE
|
|
- license/CADDY_LICENSE
|