mirror of
https://git.launchpad.net/~vhaudiquet/+git/flutter-artifacts-proxy
synced 2026-06-29 20:02:35 +00:00
Add ingress to the charm
This commit is contained in:
@@ -8,6 +8,11 @@ import logging
|
||||
import time
|
||||
|
||||
import ops
|
||||
from charms.traefik_k8s.v2.ingress import (
|
||||
IngressPerAppReadyEvent,
|
||||
IngressPerAppRequirer,
|
||||
IngressPerAppRevokedEvent,
|
||||
)
|
||||
|
||||
# A standalone module for workload-specific logic (no charming concerns):
|
||||
import charmed_server
|
||||
@@ -24,6 +29,16 @@ class CharmedServerCharm(ops.CharmBase):
|
||||
framework.observe(self.on.start, self._on_start)
|
||||
framework.observe(self.on.config_changed, self._on_config_changed)
|
||||
|
||||
self.ingress = IngressPerAppRequirer(self, port=80)
|
||||
framework.observe(self.ingress.on.ready, self._on_ingress_ready)
|
||||
framework.observe(self.ingress.on.revoked, self._on_ingress_revoked)
|
||||
|
||||
def _on_ingress_ready(self, event: IngressPerAppReadyEvent):
|
||||
logger.info("This app's ingress URL: %s", event.url)
|
||||
|
||||
def _on_ingress_revoked(self, event: IngressPerAppRevokedEvent):
|
||||
logger.info("This app no longer has ingress")
|
||||
|
||||
def _on_install(self, event: ops.InstallEvent):
|
||||
"""Install the workload on the machine."""
|
||||
charmed_server.install()
|
||||
|
||||
@@ -24,6 +24,7 @@ STATIC_SOURCE_DIR = CHARM_DIR / "src" / "static"
|
||||
CONFIG_FILE = pathops.LocalPath("/etc/nginx/nginx.conf")
|
||||
PID_FILE = pathops.LocalPath(CHARM_DIR / "nginx.pid")
|
||||
|
||||
|
||||
def ensure_config() -> bool:
|
||||
"""Ensure that nginx is configured. Return True if any changes were made."""
|
||||
config = f"""\
|
||||
@@ -53,11 +54,12 @@ http {{
|
||||
def install() -> None:
|
||||
"""Install nginx apt package."""
|
||||
apt.update()
|
||||
apt.add_package("nginx", "1.18.0-6ubuntu14.7")
|
||||
apt.add_package("nginx", "1.18.0-6ubuntu14.8")
|
||||
subprocess.check_output(["service", "nginx", "stop"])
|
||||
os.remove("/etc/nginx/nginx.conf")
|
||||
os.unlink("/etc/nginx/sites-enabled/default")
|
||||
|
||||
|
||||
def is_installed() -> bool:
|
||||
"""Check if nginx is installed."""
|
||||
return shutil.which("nginx") is not None
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
<li>This is particularly useful for riscv64 Flutter builds that Google doesn't host yet</li>
|
||||
<li>Flutter can be built for riscv64 using the following patch: <a href="https://github.com/flutter/flutter/pull/178712">PR #178712</a> (as well as a Swiftshader patch)</li>
|
||||
<li>The upstream/master Flutter tool supports riscv64, but older versions will need: <a href="https://github.com/flutter/flutter/pull/178711">PR #178711</a></li>
|
||||
<li>The first version of the Flutter tool that supports riscv64 will be 3.42</li>
|
||||
</ul>
|
||||
|
||||
<h2>Hosted artifacts:</h2>
|
||||
|
||||
Reference in New Issue
Block a user