Multiple changes:

- Stop ignoring static index file
- Automatically pull flutter artifacts from Launchpad
- Allow nginx to list files in directories
This commit is contained in:
2026-02-10 16:23:41 +01:00
parent f1c539519e
commit 2dc1a39e0b
4 changed files with 72 additions and 6 deletions

2
.gitignore vendored
View File

@@ -7,4 +7,4 @@ __pycache__/
*.py[cod]
.idea
.vscode/
src/static/
src/static/flutter_infra_release/

View File

@@ -26,4 +26,15 @@ parts:
source: .
build-snaps:
- astral-uv
flutter-3.38.9:
plugin: nil
build-packages:
- curl
override-pull: |
curl -L -O https://code.launchpad.net/~vhaudiquet/+git/flutter/+artifact/436865/+files/flutter-artifacts-riscv64.tar.gz
override-build: |
tar -C $CRAFT_PART_SRC -xzf flutter-artifacts-riscv64.tar.gz
override-prime: |
mkdir -p $CRAFT_PRIME/src/static/flutter_infra_release/flutter/587c18f873b8ab57330422bce09047420d9c7f42/
mv $CRAFT_PART_SRC/output/* $CRAFT_PRIME/src/static/flutter_infra_release/flutter/587c18f873b8ab57330422bce09047420d9c7f42/

View File

@@ -17,13 +17,12 @@ from charmlibs import apt, pathops
logger = logging.getLogger(__name__)
CONFIG_FILE = pathops.LocalPath("/etc/nginx/nginx.conf")
PID_FILE = pathops.LocalPath("/usr/local/nginx/logs/nginx.pid")
# Get the charm directory dynamically
CHARM_DIR = Path(__file__).parent.parent
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."""
@@ -39,6 +38,7 @@ http {{
listen 80;
root '{STATIC_SOURCE_DIR}';
location / {{
autoindex on;
try_files $uri $uri/ @external;
}}
location @external {{
@@ -54,7 +54,9 @@ def install() -> None:
"""Install nginx apt package."""
apt.update()
apt.add_package("nginx", "1.18.0-6ubuntu14.7")
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."""

53
src/static/index.html Normal file
View File

@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flutter Artifacts Proxy</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
max-width: 800px;
margin: 50px auto;
padding: 20px;
line-height: 1.6;
color: #333;
}
h1 {
color: #02569B;
}
.info-box {
background-color: #f0f7ff;
border-left: 4px solid #02569B;
padding: 15px;
margin: 20px 0;
}
code {
background-color: #f4f4f4;
padding: 2px 6px;
border-radius: 3px;
font-family: 'Courier New', monospace;
}
</style>
</head>
<body>
<h1>Flutter Artifacts Proxy</h1>
<div class="info-box">
<p><strong>Welcome!</strong> This is a Flutter artifacts hosting proxy.</p>
<p>It serves local Flutter artifacts first, and falls back to Google's storage servers for files not found locally.</p>
</div>
<h2>How it works</h2>
<ul>
<li>Local files are served directly, missing files are proxied to <code>https://storage.googleapis.com</code></li>
<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>
</ul>
<h2>Hosted artifacts:</h2>
<h3>Flutter 3.38.9 - <a href="flutter_infra_release/flutter/587c18f873b8ab57330422bce09047420d9c7f42/">587c18f873b8ab57330422bce09047420d9c7f42</a></h3>
<p style="margin-left: 20px;"><a href="https://code.launchpad.net/~vhaudiquet/+git/flutter/+build/207763">Launchpad build</a></p>
</body>
</html>