mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Try to fix Snap.
Thanks to xet7 !
This commit is contained in:
parent
3f2d4444e4
commit
5127e87898
1 changed files with 38 additions and 76 deletions
114
snapcraft.yaml
114
snapcraft.yaml
|
|
@ -130,33 +130,10 @@ parts:
|
||||||
- npm
|
- npm
|
||||||
stage-packages:
|
stage-packages:
|
||||||
- libfontconfig1
|
- libfontconfig1
|
||||||
override-build: |
|
override-build: |
|
||||||
set -euo pipefail
|
echo "Cleaning environment first"
|
||||||
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"
|
||||||
|
|
@ -189,9 +166,9 @@ parts:
|
||||||
# Cleanup
|
# Cleanup
|
||||||
mkdir .build
|
mkdir .build
|
||||||
cd .build
|
cd .build
|
||||||
download https://github.com/wekan/wekan/releases/download/v8.15/wekan-8.15-amd64.zip wekan-8.15-amd64.zip 6
|
wget https://github.com/wekan/wekan/releases/download/v8.16/wekan-8.16-amd64.zip
|
||||||
unzip -q wekan-8.15-amd64.zip
|
unzip wekan-8.16-amd64.zip
|
||||||
rm -f wekan-8.15-amd64.zip
|
rm wekan-8.16-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
|
||||||
|
|
@ -206,9 +183,9 @@ parts:
|
||||||
#rm fibers-multi.7z
|
#rm fibers-multi.7z
|
||||||
#cd ../../../../../../..
|
#cd ../../../../../../..
|
||||||
# Copy to Snap
|
# 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
|
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
|
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
|
||||||
|
|
@ -248,56 +225,41 @@ parts:
|
||||||
- apt-transport-https
|
- apt-transport-https
|
||||||
- gnupg
|
- gnupg
|
||||||
- curl
|
- curl
|
||||||
override-build: |
|
override-build: |
|
||||||
set -euo pipefail
|
# Add Caddy repository
|
||||||
# Resilient install of Caddy: try APT with retries, fallback to static binary
|
echo "Installing Caddy 2 from the official repository..."
|
||||||
echo "Installing Caddy 2..."
|
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /tmp/caddy-stable-archive-keyring.gpg
|
||||||
try_apt_install() {
|
mkdir -p /etc/apt/keyrings
|
||||||
echo "[caddy] Adding repository and installing via APT"
|
cp /tmp/caddy-stable-archive-keyring.gpg /etc/apt/keyrings/
|
||||||
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /tmp/caddy-stable-archive-keyring.gpg
|
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
|
||||||
mkdir -p /etc/apt/keyrings
|
apt update
|
||||||
cp /tmp/caddy-stable-archive-keyring.gpg /etc/apt/keyrings/
|
apt -y install caddy
|
||||||
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
|
|
||||||
|
|
||||||
echo "Installed Caddy version:"
|
# Display installed Caddy version for confirmation
|
||||||
/usr/bin/caddy version || true
|
echo "Installed Caddy version:"
|
||||||
|
/usr/bin/caddy version
|
||||||
|
|
||||||
# Create directory structure in the snap
|
# Create directory structure in the snap
|
||||||
mkdir -p $SNAPCRAFT_PART_INSTALL/bin
|
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 license files manually since they don't exist in the package
|
# Copy Caddy binary
|
||||||
mkdir -p $SNAPCRAFT_PART_INSTALL/license
|
cp /usr/bin/caddy $SNAPCRAFT_PART_INSTALL/bin/
|
||||||
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
|
chmod +x $SNAPCRAFT_PART_INSTALL/bin/caddy
|
||||||
|
|
||||||
# Create a basic default Caddyfile for the snap
|
# Create license files manually since they don't exist in the package
|
||||||
mkdir -p $SNAPCRAFT_PART_INSTALL/etc
|
mkdir -p $SNAPCRAFT_PART_INSTALL/license
|
||||||
cat > $SNAPCRAFT_PART_INSTALL/etc/Caddyfile << 'EOF'
|
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
|
||||||
# Default Caddyfile for Wekan
|
|
||||||
# This is loaded by caddy-control script if no other config is provided
|
|
||||||
|
|
||||||
:8080 {
|
# Create a basic default Caddyfile for the snap
|
||||||
reverse_proxy localhost:3000
|
mkdir -p $SNAPCRAFT_PART_INSTALL/etc
|
||||||
}
|
cat > $SNAPCRAFT_PART_INSTALL/etc/Caddyfile << 'EOF'
|
||||||
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:
|
stage:
|
||||||
- bin/caddy
|
- bin/caddy
|
||||||
- license/CADDY_LICENSE
|
- license/CADDY_LICENSE
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue