Skip to content

Commit

Permalink
WIP: almost got webapps working
Browse files Browse the repository at this point in the history
  • Loading branch information
davidthor committed Dec 11, 2023
1 parent 6ec894e commit 22ab03f
Show file tree
Hide file tree
Showing 14 changed files with 229 additions and 99 deletions.
3 changes: 3 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion examples/datacenters/local/datacenter.arc
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ environment {
mount_path = "/var/run/docker.sock"
}

volume {
host_path = node.inputs.dockerfile
mount_path = node.inputs.dockerfile
}

inputs = {
image = "${node.component}-${node.name}"
context = node.inputs.context
Expand Down Expand Up @@ -241,7 +246,7 @@ environment {
}

inputs = merge(node.inputs, {
service_name = "${replace(node.component + "-" + node.name, "/", "-")}"
service_name = replace(node.component + "-" + node.name, "/", "-")
hostname = "${node.inputs.subdomain}.127.0.0.1.nip.io"
})
}
Expand Down
3 changes: 2 additions & 1 deletion import_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"unique-names-generator": "https://esm.sh/v124/[email protected]",
"uuid": "https://esm.sh/v124/[email protected]",
"which": "https://esm.sh/v124/[email protected]",
"winston": "https://esm.sh/v124/[email protected]"
"winston": "https://esm.sh/v124/[email protected]",
"p-limit": "https://esm.sh/v124/[email protected]"
},
"scopes": {
"https://esm.sh/v124/": {
Expand Down
14 changes: 14 additions & 0 deletions src/@resources/webapp/inputs.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
"registry.architect.io/architect/webapp:latest"
],
"type": "string"
},
"subdomain": {
"description": "Subdomain the webapp will be served from",
"examples": [
"www"
],
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -89,6 +96,13 @@
"type": "string"
},
"type": "array"
},
"subdomain": {
"description": "Subdomain the webapp will be served from",
"examples": [
"www"
],
"type": "string"
}
},
"required": [
Expand Down
5 changes: 4 additions & 1 deletion src/@resources/webapp/outputs.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
"examples": [
443
],
"type": "number"
"type": [
"string",
"number"
]
},
"protocol": {
"description": "Protocol to access the webapp",
Expand Down
2 changes: 1 addition & 1 deletion src/@resources/webapp/outputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type WebappOutputs = {
*
* @example 443
*/
port: number;
port: string | number;
};

export default WebappOutputs;
2 changes: 1 addition & 1 deletion src/commands/common/datacenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,6 @@ export class DatacenterUtils {
});

return promises[module_path];
});
}, { concurrency: 3 });
}
}
17 changes: 15 additions & 2 deletions src/components/v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,11 @@ export default class ComponentV2 extends Component {
component_source: context.component.source,
context: webapp_config.context,
dockerfile: dockerfile,
args: {},
target: '',
},
});
graph.insertNodes(build_node);
}

let webapp_node: AppGraphNode<'webapp'>;
Expand Down Expand Up @@ -744,11 +747,21 @@ export default class ComponentV2 extends Component {
});
}

webapp_node.inputs = parseExpressionRefs(
graph,
this.normalizedDependencies,
context,
webapp_node.getId(),
webapp_node.inputs,
);

graph.insertNodes(webapp_node);

if (build_node) {
graph.insertEdges(
new GraphEdge({
from: build_node.getId(),
to: webapp_node.getId(),
from: webapp_node.getId(),
to: build_node.getId(),
}),
);
}
Expand Down
5 changes: 4 additions & 1 deletion src/datacenters/datacenter-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1902,7 +1902,10 @@ export default {
"examples": [
443
],
"type": "number"
"type": [
"string",
"number"
]
},
"protocol": {
"description": "Protocol to access the webapp",
Expand Down
5 changes: 4 additions & 1 deletion src/datacenters/datacenter.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1902,7 +1902,10 @@
"examples": [
443
],
"type": "number"
"type": [
"string",
"number"
]
},
"protocol": {
"description": "Protocol to access the webapp",
Expand Down
7 changes: 6 additions & 1 deletion src/datacenters/datacenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ export type DockerBuildFn = (options: {
context: string;
plugin: Plugin;
}) => Promise<string>;

export type DatacenterBuildOptions = {
concurrency?: number;
};

export type DockerTagFn = (
sourceRef: string,
targetName: string,
Expand Down Expand Up @@ -34,7 +39,7 @@ export abstract class Datacenter {
public abstract getGraph(appGraph: AppGraph, options: GetGraphOptions): InfraGraph;
public abstract getVariablesSchema(): DatacenterVariablesSchema;

public abstract build(buildFn: DockerBuildFn): Promise<Datacenter>;
public abstract build(buildFn: DockerBuildFn, options?: DatacenterBuildOptions): Promise<Datacenter>;
public abstract tag(tagFn: DockerTagFn): Promise<Datacenter>;
public abstract push(pushFn: DockerPushFn): Promise<Datacenter>;
}
Loading

0 comments on commit 22ab03f

Please sign in to comment.