From 18b788e66450b2b1d4e662ff5ab3ffcafded523e Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sat, 9 May 2026 20:10:24 +0800 Subject: [PATCH] ci: align docker packaging path --- README.md | 51 +++++++++++-------- apps/gpauth/Cargo.toml | 2 +- apps/gpclient/src/connect.rs | 43 ++++------------ .../docker/{cli-alpine => alpine}/Dockerfile | 1 + 4 files changed, 43 insertions(+), 54 deletions(-) rename packaging/docker/{cli-alpine => alpine}/Dockerfile (94%) diff --git a/README.md b/README.md index 7ed69b6..1fb3f02 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ A modern GlobalProtect VPN client for Linux, built on OpenConnect with full supp - [Alpine Linux](#alpine-linux) - [Gentoo](#gentoo) - [NixOS](#nixos) + - [Official Docker Image](#official-docker-image) - [Other Distributions](#other-distributions) - [Building from Source](#building-from-source) - [Frequently Asked Questions](#frequently-asked-questions) @@ -197,26 +198,6 @@ sudo apk add --allow-untrusted globalprotect-openconnect-*.apk The package uses Alpine's native musl build. Make sure the `community` repository is enabled so GUI dependencies such as `webkit2gtk-4.1`, `libsecret`, and `libayatana-appindicator` can be resolved. GUI-launched connections use polkit, and VPN tunnel creation requires `/dev/net/tun`. -#### Minimal CLI Docker Image - -For a container that only needs `gpclient`, build the Alpine CLI image from source: - -```bash -git clone https://github.com/yuezk/GlobalProtect-openconnect.git -cd GlobalProtect-openconnect -git submodule update --init --recursive -docker build -f packaging/docker/cli-alpine/Dockerfile -t gpclient-alpine . -``` - -Run it with access to the TUN device: - -```bash -docker run --rm -it --cap-add=NET_ADMIN --device=/dev/net/tun gpclient-alpine \ - connect --cookie-on-stdin -``` - -The image uses `BUILD_GUI_HELPER=0` and `INCLUDE_GUI=0`, so it does not build or install `gpgui-helper` or `gpgui`. - ### Gentoo Available via the `guru` and `lamdness` overlays: @@ -282,6 +263,36 @@ If you want it managed as part of your NixOS system configuration, use the steps sudo nixos-rebuild switch ``` +### Official Docker Image + +The official Docker image provides the CLI tools on Alpine Linux: + +```bash +docker pull yuezk/globalprotect-openconnect: +``` + +Release images are tagged as `vX.Y.Z`, `X.Y.Z`, and `latest`. + +Run it with access to the TUN device: + +```bash +docker run --rm -it --cap-add=NET_ADMIN --device=/dev/net/tun \ + yuezk/globalprotect-openconnect: \ + connect --cookie-on-stdin +``` + +For browser authentication in a headless environment, pipe `gpauth` remote-browser output into `gpclient`: + +```bash +docker run --rm -it --entrypoint gpauth yuezk/globalprotect-openconnect: \ + --browser remote 2>/dev/null \ + | docker run --rm -i --cap-add=NET_ADMIN --device=/dev/net/tun \ + yuezk/globalprotect-openconnect: \ + connect --cookie-on-stdin +``` + +The image includes `gpclient` and `gpauth` only. It does not include embedded webview authentication, `gpgui-helper`, or `gpgui`. + ### Other Distributions #### Manual Installation diff --git a/apps/gpauth/Cargo.toml b/apps/gpauth/Cargo.toml index 4b7b703..fb08b73 100644 --- a/apps/gpauth/Cargo.toml +++ b/apps/gpauth/Cargo.toml @@ -21,7 +21,7 @@ clap.workspace = true env_logger.workspace = true log.workspace = true serde_json.workspace = true -tokio.workspace = true +tokio = { workspace = true, features = ["rt-multi-thread"] } tempfile.workspace = true compile-time.workspace = true diff --git a/apps/gpclient/src/connect.rs b/apps/gpclient/src/connect.rs index 0a6c233..ead80cf 100644 --- a/apps/gpclient/src/connect.rs +++ b/apps/gpclient/src/connect.rs @@ -15,7 +15,7 @@ use gpapi::{ error::PortalError, gateway::{GatewayLogin, SessionExtensionAuth, gateway_login}, gp_params::{ClientOs, GpParams}, - portal::{Prelogin, SamlPrelogin, StandardPrelogin, prelogin, retrieve_config}, + portal::{Prelogin, StandardPrelogin, prelogin, retrieve_config}, process::{ auth_launcher::SamlAuthLauncher, users::{get_non_root_user, get_user_by_name}, @@ -154,7 +154,6 @@ pub(crate) struct ConnectArgs { #[arg(long, help = "Deprecated: Use the `--browser` option instead")] default_browser: bool, - #[cfg(feature = "webview-auth")] #[arg( long, help = "Use the specified browser to authenticate, e.g., `default`, `firefox`, `chrome`, `chromium`, `remote`.\nOr the path to the browser executable.\nUse 'remote' for headless servers.", @@ -185,36 +184,6 @@ impl ConnectArgs { Os::Mac => host_utils::get_macos_os_string(), } } - - fn saml_auth_browser<'a>(&'a self, prelogin: &SamlPrelogin) -> anyhow::Result> { - if prelogin.support_default_browser() { - return Ok(self.default_browser_saml_auth_browser()); - } - - self.embedded_saml_auth_browser() - } - - #[cfg(feature = "webview-auth")] - fn default_browser_saml_auth_browser(&self) -> Option<&str> { - self.browser.as_deref() - } - - #[cfg(not(feature = "webview-auth"))] - fn default_browser_saml_auth_browser(&self) -> Option<&str> { - None - } - - #[cfg(feature = "webview-auth")] - fn embedded_saml_auth_browser(&self) -> anyhow::Result> { - Ok(None) - } - - #[cfg(not(feature = "webview-auth"))] - fn embedded_saml_auth_browser(&self) -> anyhow::Result> { - bail!( - "The server does not support authentication via the default browser and the gpclient is not built with the `webview-auth` feature" - ); - } } pub(crate) struct ConnectHandler<'a> { @@ -569,7 +538,15 @@ impl<'a> ConnectHandler<'a> { match prelogin { Prelogin::Saml(prelogin) => { - let browser = self.args.saml_auth_browser(prelogin)?; + let browser = if prelogin.support_default_browser() { + self.args.browser.as_deref() + } else if !cfg!(feature = "webview-auth") { + bail!( + "The server does not support authentication via the default browser and the gpclient is not built with the `webview-auth` feature" + ); + } else { + None + }; let os_version = self.args.os_version(); let verbose = self.shared_args.verbose.to_verbose_arg(); let user_agent = self.user_agent(); diff --git a/packaging/docker/cli-alpine/Dockerfile b/packaging/docker/alpine/Dockerfile similarity index 94% rename from packaging/docker/cli-alpine/Dockerfile rename to packaging/docker/alpine/Dockerfile index 491da88..394d2e2 100644 --- a/packaging/docker/cli-alpine/Dockerfile +++ b/packaging/docker/alpine/Dockerfile @@ -35,6 +35,7 @@ RUN make build \ LIBXML2_STATIC=1 RUN install -Dm755 target/release/gpclient /out/usr/bin/gpclient \ + && install -Dm755 target/release/gpauth /out/usr/bin/gpauth \ && install -Dm755 packaging/files/usr/libexec/gpclient/vpnc-script /out/usr/libexec/gpclient/vpnc-script \ && install -Dm755 packaging/files/usr/libexec/gpclient/hipreport.sh /out/usr/libexec/gpclient/hipreport.sh