@atomservice/config 0.1.13 → 0.1.15
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 +3 -3
- package/server/Containerfile +10 -10
- package/src/config.service.ts +7 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomservice/config",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
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.
|
|
32
|
+
"@atomservice/gateway": "0.1.15"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@atomservice/core": "0.1.
|
|
35
|
+
"@atomservice/core": "0.1.15"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/server/Containerfile
CHANGED
|
@@ -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,26 +20,25 @@ 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 \
|
|
25
32
|
&& rm -rf /var/lib/apt/lists/*
|
|
26
33
|
|
|
27
|
-
# Create non-root user
|
|
28
|
-
RUN groupadd --system --gid 1001 app \
|
|
29
|
-
&& useradd --system --uid 1001 --gid app --no-create-home app
|
|
30
|
-
|
|
31
34
|
WORKDIR /app
|
|
32
35
|
|
|
33
36
|
# Copy compiled binary
|
|
34
|
-
COPY --from=builder
|
|
37
|
+
COPY --from=builder /build/dist/config-server ./config-server
|
|
35
38
|
|
|
36
39
|
# Prepare data directory (mount a volume here for persistence)
|
|
37
|
-
RUN mkdir -p /data
|
|
38
|
-
|
|
39
|
-
USER app
|
|
40
|
+
RUN mkdir -p /data
|
|
40
41
|
|
|
41
|
-
# Default data path — compose will bind-mount host:${containerName}/data here
|
|
42
42
|
ENV CONFIG_DB_PATH=/data/config.db
|
|
43
43
|
VOLUME ["/data"]
|
|
44
44
|
EXPOSE 4000
|
package/src/config.service.ts
CHANGED
|
@@ -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
|
|
44
|
-
|
|
45
|
-
|
|
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
|
}
|