@rcpooley/concord-kit 0.5.5 → 0.5.6

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.
@@ -249,10 +249,15 @@ export declare function assemble<H extends string, Z extends ZoneMap>(opts: {
249
249
  memory?: string | undefined;
250
250
  cpus?: string | undefined;
251
251
  user?: string | undefined;
252
+ readOnly?: boolean | undefined;
253
+ capDrop?: string[] | undefined;
254
+ noNewPrivileges?: boolean | undefined;
255
+ pidsLimit?: number | undefined;
252
256
  command?: string | string[] | undefined;
253
257
  labels?: Record<string, string> | undefined;
254
258
  }[];
255
259
  networks?: {
260
+ internal?: boolean | undefined;
256
261
  name: string;
257
262
  }[] | undefined;
258
263
  keepImages?: number | undefined;
package/dist/assemble.js CHANGED
@@ -82,6 +82,22 @@ export function assemble(opts) {
82
82
  if (m.edge)
83
83
  joined.set(host, (joined.get(host) ?? new Set()).add(network));
84
84
  }
85
+ // Networks an app owns are declared on its host whether or not anything
86
+ // joins them yet, and carry how they are made. Two apps disagreeing about
87
+ // one network is a config error, not a coin toss.
88
+ const internal = new Map();
89
+ for (const a of all) {
90
+ for (const n of a.networks ?? []) {
91
+ const key = `${a.host}/${n.name}`;
92
+ const want = n.internal ?? false;
93
+ const prior = internal.get(key);
94
+ if (prior && prior.internal !== want) {
95
+ throw new Error(`network "${n.name}" on ${a.host}: ${prior.app} declares internal: ${prior.internal}, ${a.name} declares internal: ${want}`);
96
+ }
97
+ internal.set(key, { app: a.name, internal: want });
98
+ joined.set(a.host, (joined.get(a.host) ?? new Set()).add(n.name));
99
+ }
100
+ }
85
101
  // ---- the layers ------------------------------------------------------------
86
102
  /** 1. Everything a machine needs before its docker module can act. */
87
103
  const base = machines.flatMap(([host, m]) => [
@@ -162,7 +178,7 @@ export function assemble(opts) {
162
178
  return [{
163
179
  type: 'docker', id: `apps-${host}`, host,
164
180
  ...(fleet[host].keepImages !== undefined ? { keepImages: fleet[host].keepImages } : {}),
165
- ...(nets?.size ? { networks: [...nets].map((name) => ({ name })) } : {}),
181
+ ...(nets?.size ? { networks: [...nets].map((name) => ({ name, ...(internal.get(`${host}/${name}`)?.internal ? { internal: true } : {}) })) } : {}),
166
182
  containers: c ?? [],
167
183
  }];
168
184
  });
package/dist/types.d.ts CHANGED
@@ -101,6 +101,16 @@ export type App<H extends string = string, Z extends ZoneMap = ZoneMap> = {
101
101
  */
102
102
  servedBy?: H;
103
103
  containers?: Container[];
104
+ /**
105
+ * Docker networks this app owns, when one must be made a particular way.
106
+ * Networks its containers merely join are declared on the host without
107
+ * this; list one here only to set how it is created. `internal`: no route
108
+ * out (see the docker module's network schema).
109
+ */
110
+ networks?: {
111
+ name: string;
112
+ internal?: boolean;
113
+ }[];
104
114
  /** Packages and units, for an app that is not (only) a container. Additive. */
105
115
  packages?: Package[];
106
116
  aptRepos?: AptRepo[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rcpooley/concord-kit",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "description": "Opinionated building blocks for a Concord config repo: apps as one file each, machines that derive their base layers, an nginx edge with derived certificate coverage, and assemble() to put the modules in order.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/rcpooley/concord/tree/main/kit",