@atomservice/config 0.1.12 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomservice/config",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "配置中心原子服务:基于 Bun 的高性能配置管理服务",
5
5
  "type": "module",
6
6
  "author": "openorson",
@@ -29,9 +29,9 @@
29
29
  ".": "./src/index.ts"
30
30
  },
31
31
  "dependencies": {
32
- "@atomservice/gateway": "0.1.12"
32
+ "@atomservice/gateway": "0.1.14"
33
33
  },
34
34
  "peerDependencies": {
35
- "@atomservice/core": "0.1.12"
35
+ "@atomservice/core": "0.1.14"
36
36
  }
37
37
  }
@@ -5,8 +5,9 @@ FROM oven/bun:1 AS builder
5
5
  WORKDIR /build
6
6
 
7
7
  # Install dependencies first (cache layer)
8
+ ARG NPM_REGISTRY=https://registry.npmjs.org
8
9
  COPY package.json ./
9
- RUN bun install
10
+ RUN bun install --registry ${NPM_REGISTRY}
10
11
 
11
12
  # Copy source and compile
12
13
  COPY tsconfig.json ./
@@ -19,6 +20,12 @@ RUN bun build --compile --minify --sourcemap --bytecode \
19
20
  # ── Stage 2: Minimal runtime image ───────────────────────────────────────────
20
21
  FROM debian:bookworm-slim
21
22
 
23
+ # Optionally switch apt mirror (pass --build-arg APT_MIRROR=mirrors.aliyun.com for China)
24
+ ARG APT_MIRROR=deb.debian.org
25
+ RUN if [ "${APT_MIRROR}" != "deb.debian.org" ]; then \
26
+ sed -i "s|deb.debian.org|${APT_MIRROR}|g" /etc/apt/sources.list.d/debian.sources; \
27
+ fi
28
+
22
29
  # Install curl for HEALTHCHECK (binary is ~100MB anyway, curl adds negligible overhead)
23
30
  RUN apt-get update \
24
31
  && apt-get install -y --no-install-recommends curl \
@@ -40,9 +40,13 @@ export function config(opts: ConfigOptions = {}): CallableService<ConfigInstance
40
40
  const exists = await $`podman image exists ${imageTag}`.quiet().nothrow()
41
41
  if (exists.exitCode === 0) return
42
42
  logger.info(`未找到镜像 ${imageTag},开始构建(首次较慢)…`)
43
- const build = await $`podman build -t ${imageTag} -f ${path.join(SERVER_DIR, "Containerfile")} ${SERVER_DIR}`
44
- .quiet()
45
- .nothrow()
43
+ const buildArgs: string[] = []
44
+ if (conf.mirrors?.apt) buildArgs.push("--build-arg", `APT_MIRROR=${conf.mirrors.apt}`)
45
+ if (conf.mirrors?.npm) buildArgs.push("--build-arg", `NPM_REGISTRY=${conf.mirrors.npm}`)
46
+ const build =
47
+ await $`podman build ${buildArgs} -t ${imageTag} -f ${path.join(SERVER_DIR, "Containerfile")} ${SERVER_DIR}`
48
+ .quiet()
49
+ .nothrow()
46
50
  if (build.exitCode !== 0) {
47
51
  throw new Error(`镜像构建失败:${build.stderr.toString().slice(-500)}`)
48
52
  }