getDockerComposeContents() ); $env_file_base64 = base64_encode( $this->getEnvContents() ); $activity = remoteProcess([ 'mkdir -p proxy', 'mkdir -p proxy/letsencrypt', 'cd proxy', "echo '$docker_compose_yml_base64' | base64 -d > docker-compose.yml", "echo '$env_file_base64' | base64 -d > .env", 'cat .env', ], $server, ActivityTypes::INLINE->value); return $activity; } protected function getDockerComposeContents() { return Yaml::dump($this->getComposeData()); } /** * @return array */ protected function getComposeData(): array { return [ "version" => "3.7", "networks" => [ "coolify" => [ "external" => true, ], ], "services" => [ "traefik" => [ "image" => "traefik:v2.9", "restart" => "always", "extra_hosts" => [ "host.docker.internal:host-gateway", ], "networks" => [ "coolify", ], "ports" => [ "80:80", "443:443", "8080:8080", ], "volumes" => [ "/var/run/docker.sock:/var/run/docker.sock:ro", "./letsencrypt:/letsencrypt", "./traefik.auth:/auth/traefik.auth", ], "command" => [ "--api.dashboard=true", "--api.insecure=true", "--entrypoints.http.address=:80", "--entrypoints.https.address=:443", "--providers.docker=true", "--providers.docker.exposedbydefault=false", ], "labels" => [ "traefik.enable=true", "traefik.http.routers.traefik.entrypoints=http", 'traefik.http.routers.traefik.rule=Host(`${TRAEFIK_DASHBOARD_HOST}`)', "traefik.http.routers.traefik.service=api@internal", "traefik.http.services.traefik.loadbalancer.server.port=8080", "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https", ], ], ], ]; } protected function getEnvContents() { $data = [ 'TRAEFIK_DASHBOARD_HOST' => '', 'LETS_ENCRYPT_EMAIL' => '', ]; return collect($data) ->map(fn($v, $k) => "{$k}={$v}") ->push(PHP_EOL) ->implode(PHP_EOL); } }