@layr-labs/ecloud-cli 0.0.1-dev → 0.0.1-rfc.1
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 +2 -6
- package/dist/commands/app/create.js +29 -0
- package/dist/commands/app/create.js.map +1 -0
- package/dist/commands/app/deploy.js +142 -0
- package/dist/commands/app/deploy.js.map +1 -0
- package/dist/commands/app/logs.js +108 -0
- package/dist/commands/app/logs.js.map +1 -0
- package/dist/commands/app/start.js +121 -0
- package/dist/commands/app/start.js.map +1 -0
- package/dist/commands/app/stop.js +121 -0
- package/dist/commands/app/stop.js.map +1 -0
- package/dist/commands/app/terminate.js +128 -0
- package/dist/commands/app/terminate.js.map +1 -0
- package/dist/commands/app/upgrade.js +142 -0
- package/dist/commands/app/upgrade.js.map +1 -0
- package/dist/commands/auth/generate.js +10 -116
- package/dist/commands/auth/generate.js.map +1 -1
- package/dist/commands/auth/login.js +35 -37
- package/dist/commands/auth/login.js.map +1 -1
- package/dist/commands/auth/logout.js +8 -2
- package/dist/commands/auth/logout.js.map +1 -1
- package/dist/commands/auth/migrate.js +37 -32
- package/dist/commands/auth/migrate.js.map +1 -1
- package/dist/commands/auth/whoami.js +21 -53
- package/dist/commands/auth/whoami.js.map +1 -1
- package/dist/commands/billing/cancel.js +22 -83
- package/dist/commands/billing/cancel.js.map +1 -1
- package/dist/commands/billing/status.js +29 -92
- package/dist/commands/billing/status.js.map +1 -1
- package/dist/commands/billing/subscribe.js +31 -86
- package/dist/commands/billing/subscribe.js.map +1 -1
- package/dist/keys/mainnet-alpha/prod/kms-encryption-public-key.pem +14 -0
- package/dist/keys/mainnet-alpha/prod/kms-signing-public-key.pem +4 -0
- package/dist/keys/sepolia/dev/kms-encryption-public-key.pem +14 -0
- package/dist/keys/sepolia/dev/kms-signing-public-key.pem +4 -0
- package/dist/keys/sepolia/prod/kms-encryption-public-key.pem +14 -0
- package/dist/keys/sepolia/prod/kms-signing-public-key.pem +4 -0
- package/dist/templates/Dockerfile.layered.tmpl +58 -0
- package/dist/templates/compute-source-env.sh.tmpl +110 -0
- package/package.json +4 -29
- package/VERSION +0 -2
- package/dist/commands/compute/app/configure/tls.js +0 -150
- package/dist/commands/compute/app/configure/tls.js.map +0 -1
- package/dist/commands/compute/app/create.js +0 -134
- package/dist/commands/compute/app/create.js.map +0 -1
- package/dist/commands/compute/app/deploy.js +0 -1081
- package/dist/commands/compute/app/deploy.js.map +0 -1
- package/dist/commands/compute/app/info.js +0 -809
- package/dist/commands/compute/app/info.js.map +0 -1
- package/dist/commands/compute/app/list.js +0 -570
- package/dist/commands/compute/app/list.js.map +0 -1
- package/dist/commands/compute/app/logs.js +0 -629
- package/dist/commands/compute/app/logs.js.map +0 -1
- package/dist/commands/compute/app/profile/set.js +0 -1072
- package/dist/commands/compute/app/profile/set.js.map +0 -1
- package/dist/commands/compute/app/start.js +0 -665
- package/dist/commands/compute/app/start.js.map +0 -1
- package/dist/commands/compute/app/stop.js +0 -665
- package/dist/commands/compute/app/stop.js.map +0 -1
- package/dist/commands/compute/app/terminate.js +0 -671
- package/dist/commands/compute/app/terminate.js.map +0 -1
- package/dist/commands/compute/app/upgrade.js +0 -1063
- package/dist/commands/compute/app/upgrade.js.map +0 -1
- package/dist/commands/compute/environment/list.js +0 -89
- package/dist/commands/compute/environment/list.js.map +0 -1
- package/dist/commands/compute/environment/set.js +0 -215
- package/dist/commands/compute/environment/set.js.map +0 -1
- package/dist/commands/compute/environment/show.js +0 -96
- package/dist/commands/compute/environment/show.js.map +0 -1
- package/dist/commands/compute/undelegate.js +0 -250
- package/dist/commands/compute/undelegate.js.map +0 -1
- package/dist/commands/upgrade.js +0 -91
- package/dist/commands/upgrade.js.map +0 -1
- package/dist/commands/version.js +0 -65
- package/dist/commands/version.js.map +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-----BEGIN PUBLIC KEY-----
|
|
2
|
+
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgK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A1Nl7SE/MdWKWdG6v94xNGpc2YyPP7yWtHfqOkgDWp8sokl3Uq/9
|
|
5
|
+
MS0pjUaI7RyS5boCTy8Qw90BxGMpucjOmqm+luw4EdPWZCrgriUR2bbGRRgAmrT1
|
|
6
|
+
K4ou4IgPp799r120hwHbCWxnOvLdQdpiv2507b900xS/3yZahhnHCAn66146LU/f
|
|
7
|
+
BrRpQKSM0qSpktXrrc9MH/ru2VLR5cGLp89ZcZMQA9cRGglWM5XWVY3Ti2TPJ6Kd
|
|
8
|
+
An1d7qNkGJaSdVa3x3HkOf6c6HeTyqis5/L/6L+PFhUsTRbmKg1FtwD+3xxdyf7h
|
|
9
|
+
abFxryE9rv+WatHL6r6z5ztV0znJ/Fpfs5A45FWA6pfb28fA59RGpi/DQ8RxgdCH
|
|
10
|
+
nZRNvdz8dTgRaXSPgkfGXBcCFqb/QhFmad7XbWDthGzfhbPOxNPtiaGRQ1Dr/Pgq
|
|
11
|
+
n0ugdLbRQLmDOAFgaQcnr0U4y1TUlWJnvoZMETkVN7gmITtXA4F324ALT7Rd+Lgk
|
|
12
|
+
HikW5vG+NjAEwXfPsK0YzT+VbHd7o1lbru9UxiDlN03XVEkz/oRQi47CvSTo3FSr
|
|
13
|
+
5dB4lz8kov3UUcNJfQFZolMCAwEAAQ==
|
|
14
|
+
-----END PUBLIC KEY-----
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{{#if includeTLS}}
|
|
2
|
+
# Get Caddy from official image
|
|
3
|
+
FROM caddy:2.10.2-alpine AS caddy
|
|
4
|
+
{{/if}}
|
|
5
|
+
|
|
6
|
+
FROM {{baseImage}}
|
|
7
|
+
|
|
8
|
+
{{#if originalUser}}
|
|
9
|
+
# Switch to root to perform setup (base image has non-root USER: {{originalUser}})
|
|
10
|
+
USER root
|
|
11
|
+
{{/if}}
|
|
12
|
+
|
|
13
|
+
# Copy core TEE components
|
|
14
|
+
COPY compute-source-env.sh /usr/local/bin/
|
|
15
|
+
COPY kms-client /usr/local/bin/
|
|
16
|
+
COPY kms-signing-public-key.pem /usr/local/bin/
|
|
17
|
+
|
|
18
|
+
{{#if includeTLS}}
|
|
19
|
+
# Copy Caddy from official image
|
|
20
|
+
COPY --from=caddy /usr/bin/caddy /usr/local/bin/caddy
|
|
21
|
+
|
|
22
|
+
# Copy TLS components
|
|
23
|
+
COPY tls-keygen /usr/local/bin/
|
|
24
|
+
COPY Caddyfile /etc/caddy/
|
|
25
|
+
{{/if}}
|
|
26
|
+
|
|
27
|
+
{{#if originalUser}}
|
|
28
|
+
# Make binaries executable (755 for executables, 644 for keys)
|
|
29
|
+
RUN chmod 755 /usr/local/bin/compute-source-env.sh \
|
|
30
|
+
&& chmod 755 /usr/local/bin/kms-client{{#if includeTLS}} \
|
|
31
|
+
&& chmod 755 /usr/local/bin/tls-keygen \
|
|
32
|
+
&& chmod 755 /usr/local/bin/caddy{{/if}} \
|
|
33
|
+
&& chmod 644 /usr/local/bin/kms-signing-public-key.pem
|
|
34
|
+
|
|
35
|
+
# Switch back to the original user from base image
|
|
36
|
+
USER {{originalUser}}
|
|
37
|
+
{{else}}
|
|
38
|
+
# Make binaries executable (preserve existing permissions, just add execute)
|
|
39
|
+
RUN chmod +x /usr/local/bin/compute-source-env.sh \
|
|
40
|
+
&& chmod +x /usr/local/bin/kms-client{{#if includeTLS}} \
|
|
41
|
+
&& chmod +x /usr/local/bin/tls-keygen{{/if}}
|
|
42
|
+
{{/if}}
|
|
43
|
+
|
|
44
|
+
{{#if logRedirect}}
|
|
45
|
+
|
|
46
|
+
LABEL tee.launch_policy.log_redirect={{logRedirect}}
|
|
47
|
+
{{/if}}
|
|
48
|
+
|
|
49
|
+
LABEL eigenx_cli_version={{ecloudCLIVersion}}
|
|
50
|
+
LABEL eigenx_use_ita=True
|
|
51
|
+
|
|
52
|
+
{{#if includeTLS}}
|
|
53
|
+
# Expose both HTTP and HTTPS ports for Caddy
|
|
54
|
+
EXPOSE 80 443
|
|
55
|
+
{{/if}}
|
|
56
|
+
|
|
57
|
+
ENTRYPOINT ["/usr/local/bin/compute-source-env.sh"]
|
|
58
|
+
CMD {{{originalCmd}}}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
echo "compute-source-env.sh: Running setup script..."
|
|
3
|
+
|
|
4
|
+
# Fetch and source environment variables from KMS
|
|
5
|
+
echo "Fetching secrets from KMS..."
|
|
6
|
+
if /usr/local/bin/kms-client \
|
|
7
|
+
--kms-server-url "{{kmsServerURL}}" \
|
|
8
|
+
--kms-signing-key-file /usr/local/bin/kms-signing-public-key.pem \
|
|
9
|
+
--userapi-url "{{userAPIURL}}" \
|
|
10
|
+
--output /tmp/.env; then
|
|
11
|
+
echo "compute-source-env.sh: Successfully fetched environment variables from KMS"
|
|
12
|
+
set -a && . /tmp/.env && set +a
|
|
13
|
+
rm -f /tmp/.env
|
|
14
|
+
else
|
|
15
|
+
echo "compute-source-env.sh: ERROR - Failed to fetch environment variables from KMS"
|
|
16
|
+
echo "compute-source-env.sh: Exiting - cannot start user workload without KMS secrets"
|
|
17
|
+
exit 1
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
# Setup TLS if tls-keygen is present (which means TLS was configured at build time)
|
|
21
|
+
setup_tls() {
|
|
22
|
+
# If tls-keygen isn't present, TLS wasn't configured during build
|
|
23
|
+
if [ ! -x /usr/local/bin/tls-keygen ]; then
|
|
24
|
+
echo "compute-source-env.sh: TLS not configured (no tls-keygen binary)"
|
|
25
|
+
return 0
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
local domain="${DOMAIN:-}"
|
|
29
|
+
local mnemonic="${MNEMONIC:-}"
|
|
30
|
+
|
|
31
|
+
# Since tls-keygen is present, TLS is expected - validate requirements
|
|
32
|
+
if [ -z "$domain" ] || [ "$domain" = "localhost" ]; then
|
|
33
|
+
echo "compute-source-env.sh: ERROR - TLS binary present but DOMAIN not configured or is localhost"
|
|
34
|
+
echo "compute-source-env.sh: Set DOMAIN environment variable to a valid domain"
|
|
35
|
+
exit 1
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
if [ -z "$mnemonic" ]; then
|
|
39
|
+
echo "compute-source-env.sh: ERROR - TLS binary present but MNEMONIC not available"
|
|
40
|
+
echo "compute-source-env.sh: Cannot obtain TLS certificate without mnemonic"
|
|
41
|
+
exit 1
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
if [ ! -x /usr/local/bin/caddy ]; then
|
|
45
|
+
echo "compute-source-env.sh: ERROR - TLS binary present but Caddy not found"
|
|
46
|
+
exit 1
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
echo "compute-source-env.sh: Setting up TLS for domain: $domain"
|
|
50
|
+
|
|
51
|
+
# Obtain TLS certificate using ACME
|
|
52
|
+
# Default to http-01, but allow override via ACME_CHALLENGE env var
|
|
53
|
+
local challenge="${ACME_CHALLENGE:-http-01}"
|
|
54
|
+
|
|
55
|
+
# Check if we should use staging (for testing)
|
|
56
|
+
local staging_flag=""
|
|
57
|
+
if [ "${ACME_STAGING:-false}" = "true" ]; then
|
|
58
|
+
staging_flag="-staging"
|
|
59
|
+
echo "compute-source-env.sh: Using Let's Encrypt STAGING environment (certificates won't be trusted)"
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
echo "compute-source-env.sh: Obtaining TLS certificate using $challenge challenge..."
|
|
63
|
+
# Pass the API URL for certificate persistence
|
|
64
|
+
if ! MNEMONIC="$mnemonic" DOMAIN="$domain" API_URL="{{userAPIURL}}" /usr/local/bin/tls-keygen \
|
|
65
|
+
-challenge "$challenge" \
|
|
66
|
+
$staging_flag; then
|
|
67
|
+
echo "compute-source-env.sh: ERROR - Failed to obtain TLS certificate"
|
|
68
|
+
echo "compute-source-env.sh: Certificate issuance failed for $domain"
|
|
69
|
+
exit 1
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
echo "compute-source-env.sh: TLS certificate obtained successfully"
|
|
73
|
+
|
|
74
|
+
# Validate Caddyfile before starting
|
|
75
|
+
if ! /usr/local/bin/caddy validate --config /etc/caddy/Caddyfile --adapter caddyfile 2>/dev/null; then
|
|
76
|
+
echo "compute-source-env.sh: ERROR - Invalid Caddyfile"
|
|
77
|
+
echo "compute-source-env.sh: TLS was requested (DOMAIN=$domain) but setup failed"
|
|
78
|
+
exit 1
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
# Start Caddy in background
|
|
82
|
+
echo "compute-source-env.sh: Starting Caddy reverse proxy..."
|
|
83
|
+
|
|
84
|
+
# Check if Caddy logs should be enabled
|
|
85
|
+
if [ "${ENABLE_CADDY_LOGS:-false}" = "true" ]; then
|
|
86
|
+
if ! /usr/local/bin/caddy start --config /etc/caddy/Caddyfile --adapter caddyfile 2>&1; then
|
|
87
|
+
echo "compute-source-env.sh: ERROR - Failed to start Caddy"
|
|
88
|
+
echo "compute-source-env.sh: TLS was requested (DOMAIN=$domain) but setup failed"
|
|
89
|
+
exit 1
|
|
90
|
+
fi
|
|
91
|
+
else
|
|
92
|
+
# Redirect Caddy output to /dev/null to silence logs
|
|
93
|
+
if ! /usr/local/bin/caddy start --config /etc/caddy/Caddyfile --adapter caddyfile >/dev/null 2>&1; then
|
|
94
|
+
echo "compute-source-env.sh: ERROR - Failed to start Caddy"
|
|
95
|
+
echo "compute-source-env.sh: TLS was requested (DOMAIN=$domain) but setup failed"
|
|
96
|
+
exit 1
|
|
97
|
+
fi
|
|
98
|
+
fi
|
|
99
|
+
|
|
100
|
+
# Give Caddy a moment to fully initialize
|
|
101
|
+
sleep 2
|
|
102
|
+
echo "compute-source-env.sh: Caddy started successfully"
|
|
103
|
+
return 0
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
# Run TLS setup
|
|
107
|
+
setup_tls
|
|
108
|
+
|
|
109
|
+
echo "compute-source-env.sh: Environment sourced."
|
|
110
|
+
exec "$@"
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layr-labs/ecloud-cli",
|
|
3
|
-
"version": "0.0.1-
|
|
3
|
+
"version": "0.0.1-rfc.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"bin",
|
|
8
|
-
"VERSION",
|
|
9
8
|
"README.md"
|
|
10
9
|
],
|
|
11
10
|
"bin": {
|
|
@@ -13,7 +12,7 @@
|
|
|
13
12
|
},
|
|
14
13
|
"dependencies": {
|
|
15
14
|
"@inquirer/prompts": "^7.10.1",
|
|
16
|
-
"@layr-labs/ecloud-sdk": "0.0.1-
|
|
15
|
+
"@layr-labs/ecloud-sdk": "0.0.1-rfc.1",
|
|
17
16
|
"@napi-rs/keyring": "^1.0.5",
|
|
18
17
|
"@oclif/core": "^4.8.0",
|
|
19
18
|
"axios": "^1.13.2",
|
|
@@ -28,12 +27,11 @@
|
|
|
28
27
|
"viem": "^2.38.6"
|
|
29
28
|
},
|
|
30
29
|
"scripts": {
|
|
31
|
-
"build": "tsup",
|
|
32
|
-
"
|
|
30
|
+
"build": "tsup && npm run build:copy-templates",
|
|
31
|
+
"build:copy-templates": "node scripts/copy-templates.js",
|
|
33
32
|
"lint": "eslint .",
|
|
34
33
|
"format": "prettier --check .",
|
|
35
34
|
"format:fix": "prettier --write .",
|
|
36
|
-
"typecheck": "tsc --noEmit",
|
|
37
35
|
"ecloud": "node bin/run.js"
|
|
38
36
|
},
|
|
39
37
|
"oclif": {
|
|
@@ -42,36 +40,13 @@
|
|
|
42
40
|
"dirname": "",
|
|
43
41
|
"topicSeparator": " ",
|
|
44
42
|
"topics": {
|
|
45
|
-
"auth": {
|
|
46
|
-
"description": "Manage authentication with private keys stored in OS keyring"
|
|
47
|
-
},
|
|
48
43
|
"billing": {
|
|
49
44
|
"description": "Manage billing and subscriptions"
|
|
50
|
-
},
|
|
51
|
-
"compute": {
|
|
52
|
-
"description": "Manage compute projects and resources"
|
|
53
|
-
},
|
|
54
|
-
"compute:app": {
|
|
55
|
-
"description": "Manage projects"
|
|
56
|
-
},
|
|
57
|
-
"compute:app:profile": {
|
|
58
|
-
"description": "Manage app profiles"
|
|
59
|
-
},
|
|
60
|
-
"compute:app:configure": {
|
|
61
|
-
"description": "Configure app settings"
|
|
62
|
-
},
|
|
63
|
-
"compute:environment": {
|
|
64
|
-
"description": "Manage deployment environment [alias: env]"
|
|
65
|
-
},
|
|
66
|
-
"compute:env": {
|
|
67
|
-
"hidden": true,
|
|
68
|
-
"description": "Manage deployment environment [alias: env]"
|
|
69
45
|
}
|
|
70
46
|
}
|
|
71
47
|
},
|
|
72
48
|
"devDependencies": {
|
|
73
49
|
"@types/form-data": "^2.5.2",
|
|
74
|
-
"@types/js-yaml": "^4.0.9",
|
|
75
50
|
"@types/node": "^18",
|
|
76
51
|
"ts-node": "^10.9.2"
|
|
77
52
|
}
|
package/VERSION
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/commands/compute/app/configure/tls.ts
|
|
4
|
-
import { Command } from "@oclif/core";
|
|
5
|
-
import * as fs from "fs";
|
|
6
|
-
import * as path from "path";
|
|
7
|
-
import chalk from "chalk";
|
|
8
|
-
|
|
9
|
-
// src/templates/tls/Caddyfile.tmpl
|
|
10
|
-
var Caddyfile_default = `# Caddy configuration for automatic HTTPS
|
|
11
|
-
# The DOMAIN environment variable will be injected at runtime
|
|
12
|
-
|
|
13
|
-
{$DOMAIN:localhost} {
|
|
14
|
-
# TLS configuration - always use provided certificates generated by tls-keygen
|
|
15
|
-
tls /run/tls/fullchain.pem /run/tls/privkey.pem
|
|
16
|
-
|
|
17
|
-
# Reverse proxy to your Node.js application
|
|
18
|
-
# Modify the port to match your application (default: 3000)
|
|
19
|
-
reverse_proxy localhost:{$APP_PORT:3000} {
|
|
20
|
-
# Health check configuration
|
|
21
|
-
health_uri /health
|
|
22
|
-
health_interval 30s
|
|
23
|
-
health_timeout 5s
|
|
24
|
-
health_status 200
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
# Custom headers
|
|
28
|
-
header {
|
|
29
|
-
# Security headers
|
|
30
|
-
X-Content-Type-Options "nosniff"
|
|
31
|
-
X-Frame-Options "DENY"
|
|
32
|
-
X-XSS-Protection "1; mode=block"
|
|
33
|
-
Referrer-Policy "strict-origin-when-cross-origin"
|
|
34
|
-
|
|
35
|
-
# Remove server header
|
|
36
|
-
-Server
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
# Logging
|
|
40
|
-
log {
|
|
41
|
-
output stdout
|
|
42
|
-
format console
|
|
43
|
-
level INFO
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
# Request size limits
|
|
47
|
-
request_body {
|
|
48
|
-
max_size 10MB
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
# HTTP endpoint (optional, for health checks or redirects)
|
|
53
|
-
:80 {
|
|
54
|
-
# Redirect to HTTPS only when host isn't localhost
|
|
55
|
-
@for_domain expression {host} != "localhost"
|
|
56
|
-
redir @for_domain https://{host}{uri} permanent
|
|
57
|
-
|
|
58
|
-
# Health check endpoint (always available via HTTP)
|
|
59
|
-
handle /health {
|
|
60
|
-
respond "OK" 200
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
`;
|
|
64
|
-
|
|
65
|
-
// src/templates/tls/templates.ts
|
|
66
|
-
function getCaddyfileTemplate() {
|
|
67
|
-
return Caddyfile_default;
|
|
68
|
-
}
|
|
69
|
-
var ENV_EXAMPLE_TLS = `# TLS Configuration
|
|
70
|
-
# Set these variables to enable TLS for your application
|
|
71
|
-
|
|
72
|
-
# Your domain name (required for TLS)
|
|
73
|
-
DOMAIN=yourdomain.com
|
|
74
|
-
|
|
75
|
-
# Port your application listens on
|
|
76
|
-
APP_PORT=3000
|
|
77
|
-
|
|
78
|
-
# Enable Caddy debug logs
|
|
79
|
-
ENABLE_CADDY_LOGS=false
|
|
80
|
-
|
|
81
|
-
# Use Let's Encrypt staging environment (for testing)
|
|
82
|
-
# Set to true to avoid rate limits during development
|
|
83
|
-
ACME_STAGING=false
|
|
84
|
-
|
|
85
|
-
# Force certificate reissue even if a valid one exists
|
|
86
|
-
# Useful when you need to update SANs or force a renewal
|
|
87
|
-
ACME_FORCE_ISSUE=false
|
|
88
|
-
`;
|
|
89
|
-
|
|
90
|
-
// src/commands/compute/app/configure/tls.ts
|
|
91
|
-
var ConfigureTLS = class extends Command {
|
|
92
|
-
static description = "Configure TLS for your application";
|
|
93
|
-
static summary = `Adds TLS configuration to your EigenCloud application.
|
|
94
|
-
|
|
95
|
-
This command creates:
|
|
96
|
-
- Caddyfile: Reverse proxy configuration for automatic HTTPS
|
|
97
|
-
- .env.example.tls: Example environment variables for TLS
|
|
98
|
-
|
|
99
|
-
TLS certificates are automatically obtained via Let's Encrypt using the tls-keygen tool.`;
|
|
100
|
-
async run() {
|
|
101
|
-
const cwd = process.cwd();
|
|
102
|
-
const caddyfilePath = path.join(cwd, "Caddyfile");
|
|
103
|
-
if (fs.existsSync(caddyfilePath)) {
|
|
104
|
-
this.warn("Caddyfile already exists. Skipping...");
|
|
105
|
-
} else {
|
|
106
|
-
const caddyfileContent = getCaddyfileTemplate();
|
|
107
|
-
fs.writeFileSync(caddyfilePath, caddyfileContent, { mode: 420 });
|
|
108
|
-
this.log("Created Caddyfile");
|
|
109
|
-
}
|
|
110
|
-
const envTLSPath = path.join(cwd, ".env.example.tls");
|
|
111
|
-
if (fs.existsSync(envTLSPath)) {
|
|
112
|
-
this.warn(".env.example.tls already exists. Skipping...");
|
|
113
|
-
} else {
|
|
114
|
-
fs.writeFileSync(envTLSPath, ENV_EXAMPLE_TLS, { mode: 420 });
|
|
115
|
-
this.log("Created .env.example.tls");
|
|
116
|
-
}
|
|
117
|
-
this.log("");
|
|
118
|
-
this.log(chalk.green("TLS configuration added successfully"));
|
|
119
|
-
this.log("");
|
|
120
|
-
this.log("Created:");
|
|
121
|
-
this.log(" - Caddyfile");
|
|
122
|
-
this.log(" - .env.example.tls");
|
|
123
|
-
this.log("");
|
|
124
|
-
this.log("To enable TLS:");
|
|
125
|
-
this.log("");
|
|
126
|
-
this.log("1. Add TLS variables to .env:");
|
|
127
|
-
this.log(" cat .env.example.tls >> .env");
|
|
128
|
-
this.log("");
|
|
129
|
-
this.log("2. Configure required variables:");
|
|
130
|
-
this.log(" DOMAIN=yourdomain.com");
|
|
131
|
-
this.log("");
|
|
132
|
-
this.log(" For first deployment (recommended):");
|
|
133
|
-
this.log(" ENABLE_CADDY_LOGS=true");
|
|
134
|
-
this.log(" ACME_STAGING=true");
|
|
135
|
-
this.log("");
|
|
136
|
-
this.log("3. Set up DNS A record pointing to instance IP");
|
|
137
|
-
this.log(" Run 'ecloud compute app list' to get IP address");
|
|
138
|
-
this.log("");
|
|
139
|
-
this.log("4. Upgrade:");
|
|
140
|
-
this.log(" ecloud compute app upgrade");
|
|
141
|
-
this.log("");
|
|
142
|
-
this.log("Note: Let's Encrypt rate limit is 5 certificates/week per domain");
|
|
143
|
-
this.log(" To switch staging -> production: set ACME_STAGING=false");
|
|
144
|
-
this.log(" If cert exists, use ACME_FORCE_ISSUE=true once to replace");
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
export {
|
|
148
|
-
ConfigureTLS as default
|
|
149
|
-
};
|
|
150
|
-
//# sourceMappingURL=tls.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/commands/compute/app/configure/tls.ts","../../../../../src/templates/tls/Caddyfile.tmpl","../../../../../src/templates/tls/templates.ts"],"sourcesContent":["import { Command } from \"@oclif/core\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport chalk from \"chalk\";\nimport { getCaddyfileTemplate, ENV_EXAMPLE_TLS } from \"../../../../templates/tls/templates.js\";\n\nexport default class ConfigureTLS extends Command {\n static description = \"Configure TLS for your application\";\n\n static summary = `Adds TLS configuration to your EigenCloud application.\n\nThis command creates:\n- Caddyfile: Reverse proxy configuration for automatic HTTPS\n- .env.example.tls: Example environment variables for TLS\n\nTLS certificates are automatically obtained via Let's Encrypt using the tls-keygen tool.`;\n\n async run() {\n const cwd = process.cwd();\n\n // Write Caddyfile\n const caddyfilePath = path.join(cwd, \"Caddyfile\");\n if (fs.existsSync(caddyfilePath)) {\n this.warn(\"Caddyfile already exists. Skipping...\");\n } else {\n const caddyfileContent = getCaddyfileTemplate();\n fs.writeFileSync(caddyfilePath, caddyfileContent, { mode: 0o644 });\n this.log(\"Created Caddyfile\");\n }\n\n // Write .env.example.tls\n const envTLSPath = path.join(cwd, \".env.example.tls\");\n if (fs.existsSync(envTLSPath)) {\n this.warn(\".env.example.tls already exists. Skipping...\");\n } else {\n fs.writeFileSync(envTLSPath, ENV_EXAMPLE_TLS, { mode: 0o644 });\n this.log(\"Created .env.example.tls\");\n }\n\n // Print success message and instructions\n this.log(\"\");\n this.log(chalk.green(\"TLS configuration added successfully\"));\n this.log(\"\");\n this.log(\"Created:\");\n this.log(\" - Caddyfile\");\n this.log(\" - .env.example.tls\");\n this.log(\"\");\n\n this.log(\"To enable TLS:\");\n this.log(\"\");\n this.log(\"1. Add TLS variables to .env:\");\n this.log(\" cat .env.example.tls >> .env\");\n this.log(\"\");\n\n this.log(\"2. Configure required variables:\");\n this.log(\" DOMAIN=yourdomain.com\");\n this.log(\"\");\n this.log(\" For first deployment (recommended):\");\n this.log(\" ENABLE_CADDY_LOGS=true\");\n this.log(\" ACME_STAGING=true\");\n this.log(\"\");\n\n this.log(\"3. Set up DNS A record pointing to instance IP\");\n this.log(\" Run 'ecloud compute app list' to get IP address\");\n this.log(\"\");\n\n this.log(\"4. Upgrade:\");\n this.log(\" ecloud compute app upgrade\");\n this.log(\"\");\n\n this.log(\"Note: Let's Encrypt rate limit is 5 certificates/week per domain\");\n this.log(\" To switch staging -> production: set ACME_STAGING=false\");\n this.log(\" If cert exists, use ACME_FORCE_ISSUE=true once to replace\");\n }\n}\n","# Caddy configuration for automatic HTTPS\n# The DOMAIN environment variable will be injected at runtime\n\n{$DOMAIN:localhost} {\n # TLS configuration - always use provided certificates generated by tls-keygen\n tls /run/tls/fullchain.pem /run/tls/privkey.pem\n\n # Reverse proxy to your Node.js application\n # Modify the port to match your application (default: 3000)\n reverse_proxy localhost:{$APP_PORT:3000} {\n # Health check configuration\n health_uri /health\n health_interval 30s\n health_timeout 5s\n health_status 200\n }\n\n # Custom headers\n header {\n # Security headers\n X-Content-Type-Options \"nosniff\"\n X-Frame-Options \"DENY\"\n X-XSS-Protection \"1; mode=block\"\n Referrer-Policy \"strict-origin-when-cross-origin\"\n\n # Remove server header\n -Server\n }\n\n # Logging\n log {\n output stdout\n format console\n level INFO\n }\n\n # Request size limits\n request_body {\n max_size 10MB\n }\n}\n\n# HTTP endpoint (optional, for health checks or redirects)\n:80 {\n # Redirect to HTTPS only when host isn't localhost\n @for_domain expression {host} != \"localhost\"\n redir @for_domain https://{host}{uri} permanent\n\n # Health check endpoint (always available via HTTP)\n handle /health {\n respond \"OK\" 200\n }\n}\n","/**\n * TLS configuration templates\n */\n\nimport caddyfileTemplate from \"./Caddyfile.tmpl\";\n\n/**\n * Get the Caddyfile template\n */\nexport function getCaddyfileTemplate(): string {\n return caddyfileTemplate;\n}\n\n/**\n * Embedded .env.example.tls content\n * (embedded directly since .env files are gitignored)\n */\nexport const ENV_EXAMPLE_TLS = `# TLS Configuration\n# Set these variables to enable TLS for your application\n\n# Your domain name (required for TLS)\nDOMAIN=yourdomain.com\n\n# Port your application listens on\nAPP_PORT=3000\n\n# Enable Caddy debug logs\nENABLE_CADDY_LOGS=false\n\n# Use Let's Encrypt staging environment (for testing)\n# Set to true to avoid rate limits during development\nACME_STAGING=false\n\n# Force certificate reissue even if a valid one exists\n# Useful when you need to update SANs or force a renewal\nACME_FORCE_ISSUE=false\n`;\n"],"mappings":";;;AAAA,SAAS,eAAe;AACxB,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,OAAO,WAAW;;;ACHlB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AI,sBAAsB;AAC/B,SAAK,IAAI,EAAE;AAEX,SAAK,IAAI,gBAAgB;AACzB,SAAK,IAAI,EAAE;AACX,SAAK,IAAI,+BAA+B;AACxC,SAAK,IAAI,iCAAiC;AAC1C,SAAK,IAAI,EAAE;AAEX,SAAK,IAAI,kCAAkC;AAC3C,SAAK,IAAI,0BAA0B;AACnC,SAAK,IAAI,EAAE;AACX,SAAK,IAAI,wCAAwC;AACjD,SAAK,IAAI,2BAA2B;AACpC,SAAK,IAAI,sBAAsB;AAC/B,SAAK,IAAI,EAAE;AAEX,SAAK,IAAI,gDAAgD;AACzD,SAAK,IAAI,oDAAoD;AAC7D,SAAK,IAAI,EAAE;AAEX,SAAK,IAAI,aAAa;AACtB,SAAK,IAAI,+BAA+B;AACxC,SAAK,IAAI,EAAE;AAEX,SAAK,IAAI,kEAAkE;AAC3E,SAAK,IAAI,+DAA+D;AACxE,SAAK,IAAI,iEAAiE;AAAA,EAC5E;AACF;","names":[]}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/commands/compute/app/create.ts
|
|
4
|
-
import { Command, Flags } from "@oclif/core";
|
|
5
|
-
import { createApp } from "@layr-labs/ecloud-sdk";
|
|
6
|
-
|
|
7
|
-
// src/utils/prompts.ts
|
|
8
|
-
import { input, select, password, confirm as inquirerConfirm } from "@inquirer/prompts";
|
|
9
|
-
import fs3 from "fs";
|
|
10
|
-
import path3 from "path";
|
|
11
|
-
import os3 from "os";
|
|
12
|
-
import { isAddress as isAddress2 } from "viem";
|
|
13
|
-
import { privateKeyToAccount as privateKeyToAccount2 } from "viem/accounts";
|
|
14
|
-
import {
|
|
15
|
-
getEnvironmentConfig,
|
|
16
|
-
getAvailableEnvironments,
|
|
17
|
-
isEnvironmentAvailable,
|
|
18
|
-
getAllAppsByDeveloper as getAllAppsByDeveloper2,
|
|
19
|
-
getCategoryDescriptions,
|
|
20
|
-
fetchTemplateCatalog,
|
|
21
|
-
PRIMARY_LANGUAGES,
|
|
22
|
-
validateAppName,
|
|
23
|
-
validateImageReference,
|
|
24
|
-
validateFilePath,
|
|
25
|
-
validatePrivateKeyFormat,
|
|
26
|
-
extractAppNameFromImage,
|
|
27
|
-
UserApiClient as UserApiClient2
|
|
28
|
-
} from "@layr-labs/ecloud-sdk";
|
|
29
|
-
|
|
30
|
-
// src/utils/appResolver.ts
|
|
31
|
-
import { isAddress } from "viem";
|
|
32
|
-
import { privateKeyToAccount } from "viem/accounts";
|
|
33
|
-
import {
|
|
34
|
-
UserApiClient,
|
|
35
|
-
getAllAppsByDeveloper
|
|
36
|
-
} from "@layr-labs/ecloud-sdk";
|
|
37
|
-
|
|
38
|
-
// src/utils/globalConfig.ts
|
|
39
|
-
import * as fs from "fs";
|
|
40
|
-
import * as path from "path";
|
|
41
|
-
import * as os from "os";
|
|
42
|
-
import { load as loadYaml, dump as dumpYaml } from "js-yaml";
|
|
43
|
-
import { getBuildType } from "@layr-labs/ecloud-sdk";
|
|
44
|
-
var PROFILE_CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
45
|
-
|
|
46
|
-
// src/utils/appNames.ts
|
|
47
|
-
import * as fs2 from "fs";
|
|
48
|
-
import * as path2 from "path";
|
|
49
|
-
import * as os2 from "os";
|
|
50
|
-
import { load as loadYaml2, dump as dumpYaml2 } from "js-yaml";
|
|
51
|
-
var CONFIG_DIR = path2.join(os2.homedir(), ".eigenx");
|
|
52
|
-
var APPS_DIR = path2.join(CONFIG_DIR, "apps");
|
|
53
|
-
|
|
54
|
-
// src/utils/prompts.ts
|
|
55
|
-
async function promptProjectName() {
|
|
56
|
-
return input({ message: "Enter project name:" });
|
|
57
|
-
}
|
|
58
|
-
async function promptLanguage() {
|
|
59
|
-
return select({
|
|
60
|
-
message: "Select language:",
|
|
61
|
-
choices: PRIMARY_LANGUAGES
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
async function selectTemplateInteractive(language) {
|
|
65
|
-
const catalog = await fetchTemplateCatalog();
|
|
66
|
-
const categoryDescriptions = getCategoryDescriptions(catalog, language);
|
|
67
|
-
if (Object.keys(categoryDescriptions).length === 0) {
|
|
68
|
-
throw new Error(`No templates found for language ${language}`);
|
|
69
|
-
}
|
|
70
|
-
const categories = Object.keys(categoryDescriptions).sort();
|
|
71
|
-
const options = categories.map((category) => {
|
|
72
|
-
const description = categoryDescriptions[category];
|
|
73
|
-
if (description) {
|
|
74
|
-
return { name: `${category}: ${description}`, value: category };
|
|
75
|
-
}
|
|
76
|
-
return { name: category, value: category };
|
|
77
|
-
});
|
|
78
|
-
const selected = await select({
|
|
79
|
-
message: "Select template:",
|
|
80
|
-
choices: options
|
|
81
|
-
});
|
|
82
|
-
return selected;
|
|
83
|
-
}
|
|
84
|
-
var MAX_IMAGE_SIZE = 4 * 1024 * 1024;
|
|
85
|
-
|
|
86
|
-
// src/commands/compute/app/create.ts
|
|
87
|
-
var AppCreate = class _AppCreate extends Command {
|
|
88
|
-
static description = "Create a new app from a template";
|
|
89
|
-
static flags = {
|
|
90
|
-
name: Flags.string({
|
|
91
|
-
description: "Project name"
|
|
92
|
-
}),
|
|
93
|
-
language: Flags.string({
|
|
94
|
-
description: "Programming language (typescript, golang, rust, python)",
|
|
95
|
-
options: ["typescript", "golang", "rust", "python"]
|
|
96
|
-
}),
|
|
97
|
-
"template-repo": Flags.string({
|
|
98
|
-
description: "Template name or custom template URL"
|
|
99
|
-
}),
|
|
100
|
-
"template-version": Flags.string({
|
|
101
|
-
description: "Template version/ref"
|
|
102
|
-
}),
|
|
103
|
-
verbose: Flags.boolean({
|
|
104
|
-
description: "Verbose output",
|
|
105
|
-
default: false
|
|
106
|
-
})
|
|
107
|
-
};
|
|
108
|
-
async run() {
|
|
109
|
-
const { flags } = await this.parse(_AppCreate);
|
|
110
|
-
const logger = {
|
|
111
|
-
info: (msg, ...args) => console.log(msg, ...args),
|
|
112
|
-
warn: (msg, ...args) => console.warn(msg, ...args),
|
|
113
|
-
error: (msg, ...args) => console.error(msg, ...args),
|
|
114
|
-
debug: (msg, ...args) => flags.verbose && console.debug(msg, ...args)
|
|
115
|
-
};
|
|
116
|
-
const name = flags.name || await promptProjectName();
|
|
117
|
-
const language = flags.language || await promptLanguage();
|
|
118
|
-
const template = flags["template-repo"] || await selectTemplateInteractive(language);
|
|
119
|
-
return createApp(
|
|
120
|
-
{
|
|
121
|
-
name,
|
|
122
|
-
language,
|
|
123
|
-
template: template || void 0,
|
|
124
|
-
templateVersion: flags["template-version"],
|
|
125
|
-
verbose: flags.verbose
|
|
126
|
-
},
|
|
127
|
-
logger
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
export {
|
|
132
|
-
AppCreate as default
|
|
133
|
-
};
|
|
134
|
-
//# sourceMappingURL=create.js.map
|