diff --git a/snapcraft.yaml b/snapcraft.yaml index dbea78e41..3e3e503bf 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -130,33 +130,10 @@ parts: - npm stage-packages: - libfontconfig1 - override-build: | - set -euo pipefail - echo "Cleaning environment first" + override-build: | + echo "Cleaning environment first" #rm -rf ~/.meteor ~/.npm /usr/local/lib/node_modules - 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 - } + rm -rf .build #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 "Installing npm, node-gyp, node-pre-gyp, fibers" @@ -189,9 +166,9 @@ parts: # Cleanup mkdir .build cd .build - 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 + wget https://github.com/wekan/wekan/releases/download/v8.16/wekan-8.16-amd64.zip + unzip wekan-8.16-amd64.zip + rm wekan-8.16-amd64.zip cd .. ##cd .build/bundle ##find . -type d -name '*-garbage*' | xargs rm -rf @@ -206,9 +183,9 @@ parts: #rm fibers-multi.7z #cd ../../../../../../.. # Copy to Snap - 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 + wget https://github.com/wekan/node-v14-esm/releases/download/v14.21.4/node-v14.21.4-linux-x64.tar.xz tar -xf node-v14.21.4-linux-x64.tar.xz node-v14.21.4-linux-x64/bin/node - rm -f node-v14.21.4-linux-x64.tar.xz + rm node-v14.21.4-linux-x64.tar.xz mkdir $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 @@ -248,56 +225,41 @@ parts: - apt-transport-https - gnupg - curl - override-build: | - 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 + 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 - echo "Installed Caddy version:" - /usr/bin/caddy version || true + # Display installed Caddy version for confirmation + echo "Installed Caddy version:" + /usr/bin/caddy version - # 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 + # Create directory structure in the snap + mkdir -p $SNAPCRAFT_PART_INSTALL/bin - # 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 + # Copy Caddy binary + cp /usr/bin/caddy $SNAPCRAFT_PART_INSTALL/bin/ + chmod +x $SNAPCRAFT_PART_INSTALL/bin/caddy - # 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 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 - :8080 { - reverse_proxy localhost:3000 - } - EOF + # 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 stage: - bin/caddy - license/CADDY_LICENSE