Pulumi code for my server setup
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add network and aliases

+40 -19
+40 -19
src/service.ts
··· 125 125 "image" 126 126 >; 127 127 128 + const network = new docker.Network("haring", { 129 + name: "haring", 130 + driver: "bridge", 131 + }); 132 + 128 133 export class ContainerService extends pulumi.ComponentResource { 129 134 public container: docker.Container; 130 135 ··· 162 167 ); 163 168 164 169 let labels = {}; 170 + let host; 165 171 166 172 if (args.webPort) { 173 + host = args.hostRule || `${args.domain || name}.bas.sh`; 174 + 167 175 labels = { 168 176 "traefik.enable": "true", 169 177 [`traefik.http.services.${name}.loadbalancer.server.port`]: 170 178 args.webPort.toString(), 171 - [`traefik.http.routers.${name}.rule`]: `Host(\`${args.hostRule || `${args.domain || name}.bas.sh`}\`)`, 179 + [`traefik.http.routers.${name}.rule`]: `Host(\`${host}\`)`, 172 180 [`traefik.http.routers.${name}.entrypoints`]: "https", 173 181 [`traefik.http.routers.${name}.tls`]: "true", 174 182 [`traefik.http.routers.${name}.middlewares`]: [ ··· 190 198 ...(args.envs || []), 191 199 ]; 192 200 193 - this.container = new docker.Container( 201 + const containerArgs = { 202 + image: this.image.imageId, 194 203 name, 195 - { 196 - image: this.image.imageId, 197 - name, 198 - command: args.command, 199 - restart: "always", 200 - labels: convertLabels(labels), 201 - envs, 202 - ports: convertPorts(args.ports), 203 - mounts: args.mounts, 204 - ...args.extraContainerOptions, 205 - }, 206 - { 207 - parent: this, 208 - deleteBeforeReplace: true, 209 - replaceOnChanges: ["mounts"], 210 - }, 211 - ); 204 + command: args.command, 205 + restart: "always", 206 + labels: convertLabels(labels), 207 + envs, 208 + ports: convertPorts(args.ports), 209 + mounts: args.mounts, 210 + ...args.extraContainerOptions, 211 + }; 212 + 213 + if (args.webPort && host) { 214 + containerArgs.networksAdvanced = [ 215 + { 216 + name: network.name, 217 + aliases: [host], 218 + }, 219 + ]; 220 + } else { 221 + containerArgs.networksAdvanced = [ 222 + { 223 + name: network.name, 224 + }, 225 + ]; 226 + } 227 + 228 + this.container = new docker.Container(name, containerArgs, { 229 + parent: this, 230 + deleteBeforeReplace: true, 231 + replaceOnChanges: ["mounts"], 232 + }); 212 233 213 234 this.registerOutputs({ 214 235 container: this.container,