@flisk-sh/flisk-import 0.7.0 → 0.8.0
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/README.md +1 -1
- package/dist/detectors/compose.js +6 -0
- package/dist/merge.js +1 -0
- package/dist/write.js +7 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ flisk import . --yes # write service.json files and project setup
|
|
|
15
15
|
- **Keeps:** the service names (`db` stays `db`, so it stays the hostname), the build context and Dockerfile (or the image), the container port as written (3000, 80, 5432), `depends_on`, and an HTTP health path. Databases and brokers are private, with no proxy route.
|
|
16
16
|
- **Runtime keys:** named volumes and bind mounts inside the project (`volumes`), `cap_add`, `cap_drop`, `init`, `read_only`, `user`, `security_opt` and `shm_size` (`container`), extra published ports (`extraPorts`, on 127.0.0.1 only), `network_mode: service:<name>` (`sidecarOf`) and `restart`.
|
|
17
17
|
- **Environment:** values that cannot be secrets go into the committed `service.json` `env`: numbers, `true`/`false`, another imported service's address without a user, password or query (`http://invidious:3000`, `redis:6379`), and pure `${VAR}` references. Every other name, and any name that looks like a credential (`PASSWORD`, `TOKEN`, `KEY`, ...), goes into `secrets.required`, with its literal value copied to the project `.env`, which is added to `.gitignore`. Values in `.env` already are kept.
|
|
18
|
-
- **Keeps:** a `command` on an image as the `CMD` of a
|
|
18
|
+
- **Keeps:** a `command` or `entrypoint` on an image as the `CMD`/`ENTRYPOINT` of a small `Dockerfile` next to `service.json` (Flisk sets no container command), a `healthcheck` as `healthCheck.command`, a published database port as `extraPorts`, and `restart: on-failure:N` as `on-failure`.
|
|
19
19
|
- **Drops, and says so:** `command` on a service with a `build`, `env_file` and every other untranslated key; anonymous volumes and paths outside the project; `network_mode` other than `service:<name>`; services with `profiles`, `extends`, an out-of-tree build or a `${VAR}` image.
|
|
20
20
|
- **Does not start anything.** Run `flisk up` with Flisk core **1.4.24 or later**. The importer does not check the core version.
|
|
21
21
|
- **Exit codes:** `0` when the plan succeeds (`--dry-run`, files written, or all `service.json` files already exist), `1` when no root `docker-compose.yml` or mappable service is found, and `2` when the write prompt is declined or closed without an answer (`Nothing written.`).
|
|
@@ -45,6 +45,10 @@ const TRANSLATED_KEYS = new Set([
|
|
|
45
45
|
"volumes",
|
|
46
46
|
"restart",
|
|
47
47
|
"command",
|
|
48
|
+
"entrypoint",
|
|
49
|
+
// Flisk gives every service its own stack network and container name, so these change nothing it needs.
|
|
50
|
+
"networks",
|
|
51
|
+
"expose",
|
|
48
52
|
]);
|
|
49
53
|
const CAPABILITY = /^[A-Z_]+$/;
|
|
50
54
|
const USER = /^[A-Za-z0-9_.:-]+$/;
|
|
@@ -414,6 +418,7 @@ registerDetector({
|
|
|
414
418
|
: [];
|
|
415
419
|
const command = commandOf(raw.command);
|
|
416
420
|
const containerCommand = containerCommandOf(raw.command);
|
|
421
|
+
const containerEntrypoint = containerCommandOf(raw.entrypoint);
|
|
417
422
|
const healthProbe = healthProbeOf(raw.healthcheck);
|
|
418
423
|
const envKeys = envNames(raw.environment);
|
|
419
424
|
const env = envValues(raw.environment);
|
|
@@ -502,6 +507,7 @@ registerDetector({
|
|
|
502
507
|
...(dockerfile ? { dockerfile } : {}),
|
|
503
508
|
...(command ? { command } : {}),
|
|
504
509
|
...(containerCommand ? { containerCommand } : {}),
|
|
510
|
+
...(containerEntrypoint ? { containerEntrypoint } : {}),
|
|
505
511
|
...(healthProbe ? { healthCheck: healthProbe } : {}),
|
|
506
512
|
...(selectedPort !== undefined ? { port: selectedPort } : {}),
|
|
507
513
|
...(healthCheckPath ? { healthCheckPath } : {}),
|
package/dist/merge.js
CHANGED
|
@@ -72,6 +72,7 @@ function mergeGroup(name, dir, members, resolve) {
|
|
|
72
72
|
...firstOf(ordered, "volumes"),
|
|
73
73
|
...firstOf(ordered, "restart"),
|
|
74
74
|
...firstOf(ordered, "containerCommand"),
|
|
75
|
+
...firstOf(ordered, "containerEntrypoint"),
|
|
75
76
|
...firstOf(ordered, "healthCheck"),
|
|
76
77
|
...(ordered.find((c) => c.sidecarOf)?.sidecarOf
|
|
77
78
|
? { sidecarOf: resolve(ordered.find((c) => c.sidecarOf)?.sidecarOf) }
|
package/dist/write.js
CHANGED
|
@@ -207,16 +207,18 @@ export function planWrites(plan, force) {
|
|
|
207
207
|
// Omit `image` from service.json so Flisk builds from the Dockerfile instead of pulling the tag.
|
|
208
208
|
// Flisk has no container `command`, so a Compose `command` on an image becomes the CMD of a one-line Dockerfile.
|
|
209
209
|
const files = [];
|
|
210
|
-
const wrapWithCommand = !service.dockerfile &&
|
|
210
|
+
const wrapWithCommand = !service.dockerfile &&
|
|
211
|
+
service.image &&
|
|
212
|
+
(service.containerCommand || service.containerEntrypoint);
|
|
211
213
|
if (wrapWithCommand) {
|
|
212
214
|
files.push({
|
|
213
215
|
path: resolve(dirname(path), "Dockerfile"),
|
|
214
|
-
content: `# From the Compose \`command\` of this service (flisk import). Flisk sets no container command, so it lives here.\nFROM ${service.image}\
|
|
216
|
+
content: `# From the Compose \`command\` of this service (flisk import). Flisk sets no container command, so it lives here.\nFROM ${service.image}\n${service.containerEntrypoint ? `ENTRYPOINT ${JSON.stringify(service.containerEntrypoint)}\n` : ""}${service.containerCommand ? `CMD ${JSON.stringify(service.containerCommand)}\n` : ""}`,
|
|
215
217
|
});
|
|
216
|
-
notes.push(
|
|
218
|
+
notes.push(`${service.containerEntrypoint ? "entrypoint" : "command"} ${JSON.stringify(service.containerEntrypoint ?? service.containerCommand)} is written to a Dockerfile on ${service.image}`);
|
|
217
219
|
}
|
|
218
|
-
else if (service.dockerfile && service.containerCommand) {
|
|
219
|
-
notes.push(`command
|
|
220
|
+
else if (service.dockerfile && (service.containerCommand || service.containerEntrypoint)) {
|
|
221
|
+
notes.push(`command/entrypoint not written: set it as CMD/ENTRYPOINT in ${service.dockerfile}`);
|
|
220
222
|
}
|
|
221
223
|
const source = wrapWithCommand
|
|
222
224
|
? { buildContext: ".", dockerfile: "Dockerfile" }
|
package/package.json
CHANGED