From f40fe5a86dd0ac3520a026fedaa263ac5c893adf Mon Sep 17 00:00:00 2001 From: 0xJacky Date: Wed, 13 May 2026 08:38:11 +0800 Subject: [PATCH] chore(devcontainer): use official nginx packages --- .devcontainer/Dockerfile | 16 ++++++++++++---- .devcontainer/init-nginx.sh | 21 ++++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 8aea894f..6ec8b9e7 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,10 +2,17 @@ FROM mcr.microsoft.com/devcontainers/base:noble # Combine installation steps for Nginx and Go to avoid repetitive update/cleanup commands RUN apt-get update && \ - apt-get install -y --no-install-recommends curl ca-certificates jq cloc && \ + apt-get install -y --no-install-recommends curl ca-certificates jq cloc gnupg2 lsb-release ubuntu-keyring && \ \ - # Install Nginx packages from the base system repository - apt-get install -y --no-install-recommends nginx nginx-extras inotify-tools file && \ + # Install Nginx packages from the official nginx.org repository + curl -fsSL https://nginx.org/keys/nginx_signing.key | \ + gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg && \ + echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://nginx.org/packages/ubuntu $(lsb_release -cs) nginx" > \ + /etc/apt/sources.list.d/nginx.list && \ + printf "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" > \ + /etc/apt/preferences.d/99nginx && \ + apt-get update && \ + apt-get install -y --no-install-recommends nginx inotify-tools file && \ \ # Automatically retrieve the latest stable Go version and install it, # download the appropriate binary based on system architecture (amd64 or arm64) @@ -21,7 +28,8 @@ RUN apt-get update && \ curl -sSL "https://golang.org/dl/go${GO_VERSION}.${GO_ARCH}.tar.gz" -o go.tar.gz && \ rm -rf /usr/local/go && \ tar -C /usr/local -xzf go.tar.gz && \ - rm go.tar.gz + rm go.tar.gz && \ + rm -rf /var/lib/apt/lists/* RUN cp -rp /etc/nginx /etc/nginx.orig diff --git a/.devcontainer/init-nginx.sh b/.devcontainer/init-nginx.sh index 65f0aae0..4328f408 100755 --- a/.devcontainer/init-nginx.sh +++ b/.devcontainer/init-nginx.sh @@ -17,10 +17,17 @@ create_symlink() { local target="$dest_dir/$weight-$module_name" local source="$src_dir/$module_name" + if [ ! -f "$source" ]; then + echo "Skipped missing module config: $source" + return + fi + ln -sf "$source" "$target" echo "Created symlink: $target -> $source" } +mkdir -p "$dest_dir" + modules=( "mod-http-ndk.conf 10" "mod-http-auth-pam.conf 50" @@ -45,12 +52,16 @@ modules=( "mod-stream-geoip2.conf 70" ) -for module in "${modules[@]}"; do - module_name=$(echo $module | awk '{print $1}') - weight=$(echo $module | awk '{print $2}') +if [ -d "$src_dir" ]; then + for module in "${modules[@]}"; do + module_name=$(echo $module | awk '{print $1}') + weight=$(echo $module | awk '{print $2}') - create_symlink "$module_name" "$weight" -done + create_symlink "$module_name" "$weight" + done +else + echo "Skipped module symlink creation because $src_dir does not exist" +fi # start nginx nginx