Compare commits

..

No commits in common. "main" and "2.1.18-rc1" have entirely different histories.

17 changed files with 77 additions and 225 deletions

View file

@ -11,7 +11,7 @@ name: Build image to DockerHub
on:
push:
branches: [main, dev] # Include dev branch
branches: [main]
paths:
- "docker/*/Dockerfile"
@ -38,7 +38,8 @@ jobs:
needs: setup
runs-on: ubuntu-latest
env:
MEDIA_FROM: "source" # You can set it to choice where download from
# You can set it to choice where download from
MEDIA_FROM: "source"
strategy:
matrix: ${{fromJson(needs.setup.outputs.matrix)}}
steps:
@ -52,31 +53,23 @@ jobs:
APP=${{ matrix.app }}
TAG=$(grep 'LABEL version' "docker/$APP/Dockerfile" | cut -d'"' -f2 | xargs)
echo $APP version is $TAG
# Determine the channel based on the branch and TAG
if [[ $GITHUB_REF == *"refs/heads/dev"* ]]; then
if [[ "$TAG" == *"-"* ]]; then
TAGS="$TAG"
echo "CHANNEL=dev" >> $GITHUB_ENV
TAGS="$TAG" # Use the TAG directly for dev
else
if [[ "$TAG" == *"-"* ]]; then
echo "CHANNEL=rc" >> $GITHUB_ENV
TAGS="$TAG"
else
echo "CHANNEL=release" >> $GITHUB_ENV
IFS='.' read -ra PARTS <<< "$TAG"
TAGS="latest"
TAG_PART=""
for i in "${!PARTS[@]}"; do
if [ "$i" -eq 0 ]; then
TAG_PART="${PARTS[$i]}"
else
TAG_PART="${TAG_PART}.${PARTS[$i]}"
fi
TAGS="${TAGS},${TAG_PART}"
done
fi
echo "CHANNEL=release" >> $GITHUB_ENV
IFS='.' read -ra PARTS <<< "$TAG"
TAGS="latest"
TAG_PART=""
for i in "${!PARTS[@]}"; do
if [ "$i" -eq 0 ]; then
TAG_PART="${PARTS[$i]}"
else
TAG_PART="${TAG_PART}.${PARTS[$i]}"
fi
TAGS="${TAGS},${TAG_PART}"
done
fi
echo "Building and pushing Docker image for $APP with tags: $TAGS"
echo "TAGS=$TAGS" >> $GITHUB_ENV
echo "APP=$APP" >> $GITHUB_ENV
@ -166,4 +159,4 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}
repository: websoft9dev/${{env.APP}}
readme-filepath: ${{env.README}}
if: needs.setup.outputs.matrix != ''
if: needs.setup.outputs.matrix != ''

View file

@ -5,7 +5,6 @@ on:
push:
branches:
- main
- dev
paths:
- "version.json"
@ -25,13 +24,9 @@ jobs:
version_core=${version%%-*}
echo "VERSION=$version" >> $GITHUB_OUTPUT
echo "VERSION_CORE=$version_core" >> $GITHUB_OUTPUT
if [[ $GITHUB_REF == *"refs/heads/dev"* ]]; then
echo "dev branch detected"
echo "CHANNEL=dev" >> $GITHUB_OUTPUT
elif [[ $version == *-* ]]; then
if [[ $version == *-* ]]; then
echo "rc release version"
echo "CHANNEL=rc" >> $GITHUB_OUTPUT
echo "CHANNEL=dev" >> $GITHUB_OUTPUT
else
echo "release version"
echo "CHANNEL=release" >> $GITHUB_OUTPUT
@ -76,7 +71,6 @@ jobs:
destination-dir: ./${{ steps.convert_version.outputs.CHANNEL }}/websoft9
- name: Create Github Release
if: github.ref == 'refs/heads/main' # 仅在 main 分支上触发
uses: softprops/action-gh-release@v1
with:
files: |
@ -90,7 +84,6 @@ jobs:
pages:
name: Build Github Pages
if: github.ref == 'refs/heads/main' # 仅在 main 分支上触发
permissions:
contents: read
pages: write

View file

@ -62,6 +62,7 @@ Need root privileges user to install Websoft9, if you use no-root user you can `
# Install by default
wget -O install.sh https://websoft9.github.io/websoft9/install/install.sh && bash install.sh
# Install Websoft9 with parameters
wget -O install.sh https://websoft9.github.io/websoft9/install/install.sh && bash install.sh --port 9000 --channel release --path "/data/websoft9/source" --version "latest"
```

View file

@ -1,7 +1,7 @@
[nginx_proxy_manager]
base_url = http://websoft9-proxy:81/api
user_name = admin@mydomain.com
user_pwd = LMFuCnajkQhK3zeb
user_pwd = 9KCRwcL10saLCGaZ
nike_name = admin
listen_port = 443
@ -9,18 +9,18 @@ listen_port = 443
base_url = http://websoft9-git:3000/api/v1
user_name = websoft9
user_email = admin@mydomain.com
user_pwd = 93HDu6tUWeGx
user_pwd = kk95qed0Fxt8
[portainer]
base_url = http://websoft9-deployment:9000/api
user_name = admin
user_pwd = 93sX)LLHKJY$
user_pwd = FptfbwA1TpUr
[api_key]
key = cc9223b3055471a6f4f9654e08371816a9637ba1c57383617b0684b92ac7b2f4
[domain]
wildcard_domain =
wildcard_domain =
[cockpit]
port = 9000

View file

@ -429,17 +429,15 @@ class AppManger:
# Verify the app is web app
is_web_app = envHelper.get_value("W9_URL")
# url_with_port = envHelper.get_value("W9_URL_WITH_PORT")
w9_url_with_replace = envHelper.get_value("W9_URL_REPLACE")
url_with_port = envHelper.get_value("W9_URL_WITH_PORT")
if is_web_app is not None:
if w9_url_with_replace is None:
if url_with_port is None:
envHelper.set_value("W9_URL", domain_names[0])
else:
try:
ipaddress.ip_address(domain_names[0])
#envHelper.set_value("W9_URL", domain_names[0] + ":" + envHelper.get_value("W9_HTTP_PORT_SET"))
envHelper.set_value("W9_URL", domain_names[0] + ":" + (envHelper.get_value("W9_HTTP_PORT_SET") or envHelper.get_value("W9_HTTPS_PORT_SET")))
envHelper.set_value("W9_URL", domain_names[0] + ":" + envHelper.get_value("W9_HTTP_PORT_SET"))
except ValueError:
envHelper.set_value("W9_URL", domain_names[0])
@ -601,24 +599,6 @@ class AppManger:
portainerManager.redeploy_stack(stack_id,endpointId,pull_image,user_name,user_pwd)
logger.access(f"Redeployed app: [{app_id}]")
app_info = self.get_app_by_id(app_id,endpointId)
forward_ports = [domain.get("forward_port") for domain in app_info.domain_names]
proxy_ids = [domain.get("id") for domain in app_info.domain_names]
if forward_ports:
http_port = app_info.env.get("W9_HTTP_PORT")
https_port = app_info.env.get("W9_HTTPS_PORT")
forward_port = http_port if http_port else https_port
forward_ports_str = [str(port) for port in forward_ports]
if not all(port == forward_port for port in forward_ports_str):
for proxy_id in proxy_ids:
ProxyManager().update_proxy_port_by_app(proxy_id, forward_port)
logger.access(f"Updated proxy port: {forward_port} for app: {app_id}")
def uninstall_app(self,app_id:str,purge_data:bool,endpointId:int = None):
"""
Uninstall app
@ -1102,7 +1082,7 @@ class AppManger:
# Get the w9_url and w9_url_replace
w9_url_replace = next((element.get("w9_url_replace") for element in app_info.domain_names if element.get("id") == proxy_id), None)
w9_url = next((element.get("w9_url") for element in app_info.domain_names if element.get("id") == proxy_id), None)
# validate w9_url_replace is true
if w9_url_replace:
domain_names = host.get("domain_names",None)
@ -1113,8 +1093,7 @@ class AppManger:
if w9_url in domain_names:
new_w9_url = None
if len(app_proxys) == 1 and app_proxys[0].get("id") == proxy_id:
# 如果w9_url_with_port存在并且值为: true
new_w9_url = client_host+":"+ (app_info.env.get("W9_HTTP_PORT_SET") or app_info.env.get("W9_HTTPS_PORT_SET"))
new_w9_url = client_host
elif len(app_proxys) > 1:
# Get the first proxy_host
proxy_host = next((proxy for proxy in app_proxys if proxy.get("id") != proxy_id), None)
@ -1249,4 +1228,4 @@ class AppManger:
raise e
except Exception as e:
logger.error(f"Update the git repo env file error:{e}")
raise CustomException()
raise CustomException()

View file

@ -205,44 +205,6 @@ class ProxyManager:
logger.error(f"Update proxy host:{proxy_id} error:{e}")
raise CustomException()
def update_proxy_port_by_app(self, proxy_id: int, forward_port: int):
"""
Update a proxy host's forward port
Args:
proxy_id (int): Proxy id
forward_port (int): Forward port
Returns:
dict: Proxy host
"""
# Get proxy host by id
req_json = self.get_proxy_host_by_id(proxy_id)
try:
if req_json is None:
raise CustomException(
status_code=400,
message=f"Invalid Request",
details=f"Proxy host:{proxy_id} not found"
)
# update forward_port
req_json["forward_port"] = forward_port
# delete useless keys from req_json(because the req_json is from get_proxy_host_by_id and update_proxy_host need less keys)
keys_to_delete = ["id", "created_on", "modified_on", "owner_user_id", "enabled", "certificate", "owner", "access_list", "use_default_location", "ipv6"]
for key in keys_to_delete:
req_json.pop(key, None)
response = self.nginx.update_proxy_host(proxy_id=proxy_id, json=req_json)
if response.status_code == 200:
return response.json()
else:
self._handler_nginx_error(response)
except CustomException as e:
raise e
except Exception as e:
logger.error(f"Update proxy host:{proxy_id} error:{e}")
raise CustomException()
def get_proxy_host_by_app(self,app_id:str):
"""
Get proxy host by app
@ -333,4 +295,4 @@ class ProxyManager:
except Exception as e:
logger.error(f"Get proxy host by id:{proxy_id} error:{e}")
raise CustomException()

View file

@ -1,4 +1,4 @@
APPHUB_VERSION=0.1.9
APPHUB_VERSION=0.1.6
DEPLOYMENT_VERSION=2.20.3
GIT_VERSION=1.21.9
PROXY_VERSION=2.11.3
PROXY_VERSION=2.11.3-rc9

View file

@ -1,11 +1,11 @@
# This file can running at actions
# MEDIA_VERSION and LIBRARY_VERSION will trigger its release
# modify time: 202501021450, you can modify here to trigger Docker Build action
# modify time: 202412160816, you can modify here to trigger Docker Build action
FROM python:3.10-slim-bullseye
LABEL maintainer="Websoft9<help@websoft9.com>"
LABEL version="0.1.9"
LABEL version="0.1.6"
WORKDIR /websoft9
@ -39,7 +39,6 @@ RUN apt update && apt install -y --no-install-recommends curl git jq cron iprout
cp -r ./w9source/apphub/src/config ./config && \
cp -r ./w9source/docker/apphub/script ./script && \
curl -o ./script/update_zip.sh $SOURCE_GITHUB_PAGES/scripts/update_zip.sh && \
curl -o /websoft9/version.json $SOURCE_GITHUB_PAGES/version.json && \
pip install --no-cache-dir --upgrade -r apphub/requirements.txt && \
pip install -e ./apphub && \
# Clean cache and install files
@ -47,9 +46,6 @@ RUN apt update && apt install -y --no-install-recommends curl git jq cron iprout
apt clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/man /usr/share/doc /usr/share/doc-base
# Create a file named migration_flag
RUN touch /websoft9/migration_flag
# supervisor
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY config/logging_config.yaml /etc/supervisor/conf.d/logging_config.yaml

View file

@ -6,11 +6,7 @@ export PATH
set -e
# execute migration script when container create
if [ -f /websoft9/migration_flag ]; then
bash /websoft9/script/migration.sh
rm -f /websoft9/migration_flag
fi
bash /websoft9/script/migration.sh
try_times=5
supervisord

View file

@ -3,9 +3,10 @@
echo "$(date '+%Y-%m-%d %H:%M:%S') - INFO - start to migrate config.ini"
migrate_ini() {
# Combine source_ini to target ini
# Define file paths, use template ini and syn exsit items from target ini
export target_ini="$1"
export source_ini="$2"
export template_ini="$2"
python3 - <<EOF
import configparser
@ -13,44 +14,36 @@ import os
import sys
target_ini = os.environ['target_ini']
source_ini = os.environ['source_ini']
template_ini = os.environ['template_ini']
# Create two config parsers
target_parser = configparser.ConfigParser()
source_parser = configparser.ConfigParser()
template_parser = configparser.ConfigParser()
try:
target_parser.read(target_ini)
source_parser.read(source_ini)
template_parser.read(template_ini)
except configparser.MissingSectionHeaderError:
print("Error: The provided files are not valid INI files.")
sys.exit(1)
# use target_parser to override source_parser
# use target_parser to override template_parser
for section in target_parser.sections():
if source_parser.has_section(section):
if template_parser.has_section(section):
for key, value in target_parser.items(section):
if source_parser.has_option(section, key):
source_parser.set(section, key, value)
if template_parser.has_option(section, key):
template_parser.set(section, key, value)
with open(target_ini, 'w') as f:
source_parser.write(f)
template_parser.write(f)
EOF
}
# Special migration
post_migration(){
echo "$(date '+%Y-%m-%d %H:%M:%S') - INFO - Set listen_port to nginx_proxy_manager"
config_file="/websoft9/config/config.ini"
listen_port=$(grep -Po '^\s*listen_port\s*=\s*\K[0-9]+' "$config_file")
apphub setconfig --section nginx_proxy_manager --key listen_port --value "$listen_port"
}
migrate_ini "/websoft9/apphub/src/config/config.ini" "/websoft9/config/config.ini"
migrate_ini "/websoft9/apphub/src/config/system.ini" "/websoft9/config/system.ini"
post_migration
if [ $? -eq 0 ]; then
echo "$(date '+%Y-%m-%d %H:%M:%S') - INFO - Success to update config.ini"

View file

@ -1,20 +1,9 @@
#!/bin/bash
channel=release
if [ -f /websoft9/version.json ]; then
version=$(cat /websoft9/version.json | jq -r .version)
if [[ $version == *rc* ]]; then
channel=dev
fi
fi
echo "channel is $channel"
echo "$(date '+%Y-%m-%d %H:%M:%S') - INFO - Compare remote version and local version." | tee -a /var/log/supervisord.log
echo "$(date '+%Y-%m-%d %H:%M:%S') - INFO - Download remote packages and replace local data." | tee -a /var/log/supervisord.log
bash /websoft9/script/update_zip.sh --channel $channel --package_name "media-latest.zip" --sync_to "/websoft9/media"
bash /websoft9/script/update_zip.sh --channel $channel --package_name "library-latest.zip" --sync_to "/websoft9/library"
echo "$(date '+%Y-%m-%d %H:%M:%S') - INFO - Download remote packages and replace local data." | tee -a /var/log/supervisord.log
bash /websoft9/script/update_zip.sh --package_name "media-latest.zip" --sync_to "/websoft9/media"
bash /websoft9/script/update_zip.sh --package_name "library-latest.zip" --sync_to "/websoft9/library"
echo "$(date '+%Y-%m-%d %H:%M:%S') - INFO - Success to update library and media."

View file

@ -1,11 +1,11 @@
# modify time: 202412211783, you can modify here to trigger Docker Build action
# modify time: 202412131435, you can modify here to trigger Docker Build action
# from Dockerfile: https://github.com/NginxProxyManager/nginx-proxy-manager/blob/develop/docker/Dockerfile
# from image: https://hub.docker.com/r/jc21/nginx-proxy-manager
FROM jc21/nginx-proxy-manager:2.11.3
LABEL maintainer="Websoft9<help@websoft9.com>"
LABEL version="2.11.3"
LABEL version="2.11.3-rc9"
COPY README.md /data/nginx/README.md
RUN mkdir /data/nginx/custom

View file

@ -23,7 +23,7 @@ server {
}
location / {
root /data/nginx/default_www/landing;
root /etc/websoft9/landing;
index index.html
# Proxy!
include conf.d/include/proxy.conf;

View file

@ -8,13 +8,6 @@ if [ ! -d /data/nginx/default_host ]; then mkdir -p /data/nginx/default_host; fi
cp -f /etc/websoft9/initproxy.conf /data/nginx/default_host/initproxy.conf
[ -f /etc/websoft9/initproxy.conf ] && rm -f /data/nginx/proxy_host/initproxy.conf
# Deploy Websoft9 landing pages
if [ ! -d /data/nginx/default_www/landing ]; then
mkdir -p /data/nginx/default_www/
cp -r /etc/websoft9/landing /data/nginx/default_www/
else
echo "/data/nginx/default_www/landing already exists."
fi
# If credential file then create it and init credential for NPM
# Reload NPM docker image Environments

View file

@ -18,7 +18,7 @@ export PATH
#
# $ sudo bash install.sh --port 9001
#
# --channel <release|rc|dev>
# --channel <release|dev>
# Use the --channel option to install a release(production) or dev distribution. default is release, for example:
#
# $ sudo bash install.sh --channel release
@ -302,35 +302,6 @@ install_tools(){
fi
}
download_artifact() {
local artifact_url="$1"
local source_zip="$2"
local max_attempts="$3"
for ((i=1; i<=max_attempts; i++)); do
wget -P /tmp "$artifact_url/$source_zip"
if [ $? -eq 0 ]; then
echo "Downloaded successfully using wget on attempt $i."
return 0
else
echo "Attempt $i failed using wget."
fi
done
for ((i=1; i<=max_attempts; i++)); do
curl -o /tmp/"$source_zip" "$artifact_url/$source_zip"
if [ $? -eq 0 ]; then
echo "Downloaded successfully using curl on attempt $i."
return 0
else
echo "Attempt $i failed using curl."
fi
done
echo "Failed to download source package after $((max_attempts * 2)) attempts."
return 1
}
download_source_and_checkimage() {
echo_prefix_source=$'\n[Download Source] - '
echo "$echo_prefix_source Download Websoft9 source code from $artifact_url/$source_zip"
@ -338,7 +309,7 @@ download_source_and_checkimage() {
find . -type f -name "websoft9*.zip*" -exec rm -f {} \;
rm -rf /tmp/$source_unzip
download_artifact "$artifact_url" "$source_zip" 10
wget -P /tmp "$artifact_url/$source_zip"
if [ $? -ne 0 ]; then
echo "Failed to download source package."
exit 1

View file

@ -4,9 +4,6 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
cockpit_port="9000"
container_name="websoft9-apphub"
volume_name="websoft9_apphub_config"
cockpit_service_path="/lib/systemd/system/cockpit.socket"
cockpit_ssl_path="/etc/cockpit/ws-certs.d/"
npm_ssl_path="/var/lib/docker/volumes/websoft9_nginx_data/_data/custom_ssl/"
# get volume from container
function get_volume_path() {
@ -31,12 +28,14 @@ function get_volume_path() {
echo "Cannot get volume path"
exit 1
}
volume_path=$(get_volume_path "$container_name" "$volume_name")
config_path="$volume_path/config.ini"
cockpit_service_path="/lib/systemd/system/cockpit.socket"
FILES="$cockpit_service_path $config_path"
sync_cockpit_port() {
echo "sync cockpit port from config.ini"
# 监控文件发生变动时需要做的事情
on_change() {
set +e
cockpit_port=$(docker exec -i websoft9-apphub apphub getconfig --section cockpit --key port)
listen_stream=$(grep -Po 'ListenStream=\K[0-9]*' /lib/systemd/system/cockpit.socket)
@ -59,32 +58,19 @@ set_Firewalld(){
firewall-cmd --reload 2>/dev/nul
}
force_sync(){
echo "Force sync cockpit port and certs"
sync_cockpit_port
cp -r "${cockpit_ssl_path}"* $npm_ssl_path
}
# when websoft9 restart, sync cockpit port and ssl
on_change
cp -r /etc/cockpit/ws-certs.d/* /var/lib/docker/volumes/websoft9_nginx_data/_data/custom_ssl/
# when websoft9 restart, force sync cockpit port and certs
force_sync
# monitor /lib/systemd/system/cockpit.socket and config.ini, make sure config.ini port is the same with cockpit.socket
inotifywait -e modify,attrib -m $FILES | while read PATH EVENT FILE; do
echo "Set cockpit port by config.ini..."
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
on_change
done
(
# monitor cockpit.socket and config.ini, make sure port at config.ins sync to cockpit.socket
inotifywait -e modify,attrib -m $FILES | while read PATH EVENT FILE; do
echo "Reset cockpit port when config.ini changed"
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
sync_cockpit_port
done
) &
(
# monitor cockpit ssl path and sync to NPM ssl path if changed
inotifywait -e create,modify,delete,attrib -m $cockpit_ssl_path | while read PATH EVENT FILE; do
echo "Sync CA files from cockipt to NPM when changed"
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
cp -r "${cockpit_ssl_path}"* $npm_ssl_path
done
) &
# Wait for background processes to finish
wait
# monitor /etc/cockpit/ws-certs.d and copy files to /var/lib/docker/volumes/websoft9_nginx_data/_data/custom_ssl
inotifywait -e create,modify,delete -m /etc/cockpit/ws-certs.d | while read PATH EVENT FILE; do
echo "Copying files from /etc/cockpit/ws-certs.d to /var/lib/docker/volumes/websoft9_nginx_data/_data/custom_ssl..."
cp -r /etc/cockpit/ws-certs.d/* /var/lib/docker/volumes/websoft9_nginx_data/_data/custom_ssl/
done

View file

@ -1,5 +1,5 @@
{
"version": "2.1.20",
"version": "2.1.18-rc1",
"plugins": {
"portainer": "0.1.3",
"nginx": "0.1.0",
@ -11,8 +11,8 @@
},
"OS": {
"Fedora": [
"41",
"40"
"40",
"39"
],
"RedHat": [
"9",