Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
299 changes: 283 additions & 16 deletions deno.lock

Large diffs are not rendered by default.

159 changes: 159 additions & 0 deletions examples/datacenters/local/datacenter.arc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module "traefik" {
name = "${datacenter.name}-gateway"
image = "traefik:v2.10"
command = [
"--accesslog=true",
"--providers.docker=true",
"--api.insecure=true",
"--api.dashboard=true"
Expand Down Expand Up @@ -68,6 +69,57 @@ environment {
}
}

module "staticWebServer" {
when = contains(environment.nodes.*.type, "bucket")
build = "./deployment"

volume {
host_path = "/var/run/docker.sock"
mount_path = "/var/run/docker.sock"
}

volume {
host_path = "${var.secretsDir}/${environment.name}/buckets/"
mount_path = "/usr/share/nginx/html"
}

environment = {
DOCKER_HOST = "unix:///var/run/docker.sock"
}

inputs = {
name = "${environment.name}-static-web-server"
image = "nginx"
}
}

module "localstack" {
// when = contains(environment.nodes.*.type, "bucket")
build = "./deployment"

volume {
host_path = "/var/run/docker.sock"
mount_path = "/var/run/docker.sock"
}

environment = {
DOCKER_HOST = "unix:///var/run/docker.sock"
}

inputs = {
name = "localstack"
image = "localstack/localstack"
ports = [{
internal = 4566
external = 4566
}]
environment = {
DOCKER_HOST = "unix:///var/run/docker.sock"
GATEWAY_LISTEN = "0.0.0.0:4566"
}
}
}

database {
when = node.inputs.databaseType == "postgres"

Expand Down Expand Up @@ -203,4 +255,111 @@ environment {
image = module.build.image
}
}

volume {
module "volume" {
build = "./volume"

environment = {
DOCKER_HOST = "unix:///var/run/docker.sock"
}

volume {
host_path = "/var/run/docker.sock"
mount_path = "/var/run/docker.sock"
}

inputs = {
name = "${node.component}-${node.name}"
}
}

outputs = {
id = module.volume.id
}
}

task {
module "task" {
build = "./deployment"

environment = {
DOCKER_HOST = "unix:///var/run/docker.sock"
}

volume {
host_path = "/var/run/docker.sock"
mount_path = "/var/run/docker.sock"
}

inputs = "${merge(node.inputs, {
volume_mounts = merge(node.inputs.volume_mounts, [{
host_path = "/var/run/docker.sock",
mount_path = "/var/run/docker.sock"
}])
})}"
}
}

// bucket {
// module "dynamicBucket" {
// when = node.inputs.deploy
// build = "./deployment"

// environment = {
// DOCKER_HOST = "unix:///var/run/docker.sock"
// }

// volume {
// host_path = "/var/run/docker.sock"
// mount_path = "/var/run/docker.sock"
// }

// # This volume is shared with the nginx webserver
// volume {
// host_path = "${var.secretsDir}/${environment.name}/buckets/"
// mount_path = "/data"
// }

// inputs = merge(node.inputs.deploy, {
// volume_mounts = [{
// host_path = "/data"
// mount_path = node.inputs.deploy.publish
// }]
// })
// }

// module "staticBucket" {
// when = node.inputs.directory
// build = "./deployment"

// environment = {
// DOCKER_HOST = "unix:///var/run/docker.sock"
// }

// volume {
// host_path = "/var/run/docker.sock"
// mount_path = "/var/run/docker.sock"
// }

// # This volume is shared with the nginx webserver
// volume {
// host_path = "${var.secretsDir}/${environment.name}/buckets/"
// mount_path = "/data"
// }

// inputs = {
// image = "alpine"
// command = [
// "sh",
// "-c",
// "cp -r ${node.inputs.directory} /data"
// ]
// volume_mounts = [{
// host_path = "/data"
// mount_path = "/data"
// }]
// }
// }
// }
}
17 changes: 10 additions & 7 deletions examples/datacenters/local/deployment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const config = new pulumi.Config();
export const name = config.require('name');

type Config = {
name?: string;
name: string;
image: string;
command?: string[];
entrypoint?: string[];
Expand Down Expand Up @@ -90,23 +90,26 @@ for (const key in inputServices) {
const inputIngresses = config.getObject<Config['ingresses']>('ingresses') || [];
for (const key in inputIngresses) {
const value = inputIngresses[key];
const routerKey = value.subdomain.replace(/\./g, '-').replace(/\*/g, 'star');
if (value.protocol === 'http') {
labels.push({
label: `traefik.http.routers.${value.subdomain}.rule`,
value: `Host(\`${value.host}\`) && PathPrefix(\`${value.path || '/'}\`)`,
label: `traefik.http.routers.${routerKey}.rule`,
value: value.host.includes('*')
? `HostRegexp(\`${value.host.replace('*', '{subdomain:[a-z_-]+}')}\`) && PathPrefix(\`${value.path || '/'}\`)`
: `Host(\`${value.host}\`) && PathPrefix(\`${value.path || '/'}\`)`,
}, {
label: `traefik.http.routers.${value.subdomain}.service`,
label: `traefik.http.routers.${routerKey}.service`,
value: value.service,
});
} else {
labels.push({
label: `traefik.tcp.routers.${value.subdomain}.rule`,
label: `traefik.tcp.routers.${routerKey}.rule`,
value: `HostSNI(\`${value.host}\`)`
}, {
label: `traefik.tcp.routers.${value.subdomain}.service`,
label: `traefik.tcp.routers.${routerKey}.service`,
value: value.service,
}, {
label: `traefik.tcp.routers.${value.subdomain}.tls.passthrough`,
label: `traefik.tcp.routers.${routerKey}.tls.passthrough`,
value: 'true',
});
}
Expand Down
16 changes: 0 additions & 16 deletions examples/datacenters/local/network/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,6 @@ import * as pulumi from "@pulumi/pulumi";

let config = new pulumi.Config();

type Config = {
name?: string;
image: string;
command?: string[];
labels?: Record<string, string>;
services?: Record<string, {
hostname: string;
port: number;
protocol: string;
}>;
ports?: {
internal: number;
external?: number;
}[];
};

const network = new docker.Network('network', {
name: config.get('name'),
});
Expand Down
1 change: 1 addition & 0 deletions src/@resources/bucket/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# The `bucket` resource
10 changes: 10 additions & 0 deletions src/@resources/bucket/inputs.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$ref": "#/definitions/BucketInputs",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"BucketInputs": {
"additionalProperties": {},
"type": "object"
}
}
}
3 changes: 3 additions & 0 deletions src/@resources/bucket/inputs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type BucketInputs = Record<string, unknown>;

export default BucketInputs;
46 changes: 46 additions & 0 deletions src/@resources/bucket/outputs.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"$ref": "#/definitions/BucketOutputs",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"BucketOutputs": {
"additionalProperties": false,
"properties": {
"access_key_id": {
"description": "Access key ID used to authenticate with the bucket",
"type": "string"
},
"endpoint": {
"description": "Endpoint that hosts the bucket",
"examples": [
"https://nyc3.digitaloceanspaces.com",
"https://bucket.s3.region.amazonaws.com"
],
"type": "string"
},
"id": {
"description": "Unique ID of the bucket that was created",
"examples": [
"abc123"
],
"type": "string"
},
"region": {
"description": "Region the bucket was created in",
"type": "string"
},
"secret_access_key": {
"description": "Secret access key used to authenticate with the bucket",
"type": "string"
}
},
"required": [
"id",
"endpoint",
"region",
"access_key_id",
"secret_access_key"
],
"type": "object"
}
}
}
32 changes: 32 additions & 0 deletions src/@resources/bucket/outputs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export type BucketOutputs = {
/**
* Unique ID of the bucket that was created
* @example "abc123"
*/
id: string;

/**
* Endpoint that hosts the bucket
*
* @example "https://nyc3.digitaloceanspaces.com"
* @example "https://bucket.s3.region.amazonaws.com"
*/
endpoint: string;

/**
* Region the bucket was created in
*/
region: string;

/**
* Access key ID used to authenticate with the bucket
*/
access_key_id: string;

/**
* Secret access key used to authenticate with the bucket
*/
secret_access_key: string;
};

export default BucketOutputs;
Loading