0
0

Updated SearXNG

This commit is contained in:
Opnxng 2024-05-20 18:14:19 +08:00
parent 32f1b3c9a0
commit 92f333186d
2 changed files with 8 additions and 75 deletions

View File

@ -1,8 +1,7 @@
name: searxng name: searxng
#run-name: searxng run-name: searxng
env: env:
REMOTE_REPO: https://paulgo.dev/infra/paulgoio/searxng.git REMOTE_REPO: https://github.com/searxng/searxng.git
SEARXNG_REPO: https://github.com/searxng/searxng.git
BUILD_PLATFORM: linux/arm64 BUILD_PLATFORM: linux/arm64
on: on:
schedule: schedule:
@ -12,70 +11,6 @@ on:
- ".gitea/workflows/searxng.yaml" - ".gitea/workflows/searxng.yaml"
jobs: jobs:
build-searxng-base:
runs-on: runner
container:
image: docker:cli
env:
REPO_NAME: searxng-base
steps:
- name: Install packages
run: apk --no-cache add curl git jq
- name: Check latest upstream commit
run: |
STORED_COMMIT=$(curl -H "Authorization: Bearer ${{ secrets.NT }}" -s "https://nt.opnxng.com/${REPO_NAME}/raw?poll=1" | tail -n 1)
LATEST_COMMIT=$(git ls-remote --heads ${REMOTE_REPO} | grep "refs/heads/base" | awk '{print $1}') # use base branch
echo "STORED_COMMIT=${STORED_COMMIT}" >> "$GITHUB_ENV"
echo "LATEST_COMMIT=${LATEST_COMMIT}" >> "$GITHUB_ENV"
echo "Stored Commit: ${STORED_COMMIT}"
echo "Latest Commit: ${LATEST_COMMIT}"
- name: Build and push Docker image
run: |
if [ "$STORED_COMMIT" != "$LATEST_COMMIT" ]; then
echo "Found a new commit, building new image"
# Install Docker Buildx
BUILDX_VERSION=$(wget -q -O- https://api.github.com/repos/docker/buildx/releases/latest | jq -r '.name')
wget -O /usr/bin/docker-buildx https://github.com/docker/buildx/releases/download/$BUILDX_VERSION/buildx-$BUILDX_VERSION.linux-arm64
chmod +x /usr/bin/docker-buildx
# Create and use Docker Buildx builder
docker-buildx create --use --name buildx
# Login to Package Registry
echo "${{ secrets.TOKEN }}" | docker login git.opnxng.com -u ${{ gitea.repository_owner }} --password-stdin
# Build and push Docker image
mkdir temp
cd temp
git clone ${REMOTE_REPO} .
git checkout base # Use base branch to build the base image
docker-buildx build \
--platform ${BUILD_PLATFORM} \
-t git.opnxng.com/${{ gitea.repository_owner }}/searxng:base \
-f ./Dockerfile \
--push . && \
curl -H prio:low -d "Built and pushed ${REPO_NAME}" https://ntfy.opnxng.com/build || \
{ curl -H tags:warning -H prio:high -d "Built and pushed ${REPO_NAME} failed!" https://ntfy.opnxng.com/build ; exit 1; }
# Remove Docker Buildx builder
docker-buildx rm buildx
else
echo "No new commit, skipped build"
fi
- name: Update stored commit
run: |
if [ "$STORED_COMMIT" != "$LATEST_COMMIT" ]; then
curl -H "Authorization: Bearer ${{ secrets.NT }}" -d $(git ls-remote --heads ${REMOTE_REPO} | grep "refs/heads/base" | awk '{print $1}') "https://nt.opnxng.com/${REPO_NAME}" # use base branch
STORED_COMMIT=$(curl -H "Authorization: Bearer ${{ secrets.NT }}" -s "https://nt.opnxng.com/${REPO_NAME}/raw?poll=1" | tail -n 1)
echo "STORED_COMMIT=${STORED_COMMIT}" >> "$GITHUB_ENV"
else
curl -H "Authorization: Bearer ${{ secrets.NT }}" -d $(git ls-remote --heads ${REMOTE_REPO} | grep "refs/heads/base" | awk '{print $1}') "https://nt.opnxng.com/${REPO_NAME}" # use base branch
STORED_COMMIT=$(curl -H "Authorization: Bearer ${{ secrets.NT }}" -s "https://nt.opnxng.com/${REPO_NAME}/raw?poll=1" | tail -n 1)
echo "STORED_COMMIT=${STORED_COMMIT}" >> "$GITHUB_ENV"
exit 0 # Continue to next step no matter what
fi
#----------------------------------------------------------------------------------------------------
build-searxng: build-searxng:
runs-on: runner runs-on: runner
container: container:
@ -89,9 +24,7 @@ jobs:
- name: Check latest upstream commit - name: Check latest upstream commit
run: | run: |
STORED_COMMIT=$(curl -H "Authorization: Bearer ${{ secrets.NT }}" -s "https://nt.opnxng.com/${REPO_NAME}/raw?poll=1" | tail -n 1) STORED_COMMIT=$(curl -H "Authorization: Bearer ${{ secrets.NT }}" -s "https://nt.opnxng.com/${REPO_NAME}/raw?poll=1" | tail -n 1)
# LATEST_COMMIT=$(git ls-remote ${REMOTE_REPO} | awk '{print $1}' | head -1) LATEST_COMMIT=$(git ls-remote ${REMOTE_REPO} | awk '{print $1}' | head -1)
# Use upstream SearXNG repo
LATEST_COMMIT=$(git ls-remote ${SEARXNG_REPO} | awk '{print $1}' | head -1)
echo "STORED_COMMIT=${STORED_COMMIT}" >> "$GITHUB_ENV" echo "STORED_COMMIT=${STORED_COMMIT}" >> "$GITHUB_ENV"
echo "LATEST_COMMIT=${LATEST_COMMIT}" >> "$GITHUB_ENV" echo "LATEST_COMMIT=${LATEST_COMMIT}" >> "$GITHUB_ENV"
echo "Stored Commit: ${STORED_COMMIT}" echo "Stored Commit: ${STORED_COMMIT}"
@ -112,11 +45,7 @@ jobs:
# Build and push Docker image # Build and push Docker image
mkdir temp mkdir temp
cd temp cd temp
git clone ${REMOTE_REPO} . curl -JL https://git.opnxng.com/opnxng/docker-images/raw/branch/main/dockerfiles/searxng.Dockerfile -o Dockerfile
# UPSTREAM_COMMIT=$(git ls-remote ${REMOTE_REPO} | awk '{print $1}' | head -1)
UPSTREAM_COMMIT=$(git ls-remote ${SEARXNG_REPO} | awk '{print $1}' | head -1)
sed -i "s/UPSTREAM_COMMIT=.*/UPSTREAM_COMMIT=$UPSTREAM_COMMIT/" Dockerfile
sed -i 's/FROM registry.paulgo.dev\/infra\/paulgoio\/searxng:base/FROM git.opnxng.com\/opnxng\/searxng:base/' Dockerfile # use git.opnxng.com/opnxng/searxng:base
docker-buildx build \ docker-buildx build \
--platform ${BUILD_PLATFORM} \ --platform ${BUILD_PLATFORM} \
-t git.opnxng.com/${{ gitea.repository_owner }}/${REPO_NAME}:latest \ -t git.opnxng.com/${{ gitea.repository_owner }}/${REPO_NAME}:latest \

View File

@ -0,0 +1,4 @@
FROM docker.io/searxng/searxng:latest
# copy custom simple theme css from the PaulGo fork
COPY --from=docker.io/paulgoio/searxng:production /usr/local/searxng/searx/static/themes/ /usr/local/searxng/searx/static/themes/