mirror of
git://f0xx.org/android_cast
synced 2026-07-29 08:37:37 +03:00
orchestration beginning
This commit is contained in:
@@ -6,6 +6,7 @@ LANDING_HTTP_PORT=8080
|
||||
# Optional direct debug ports
|
||||
GITEA_FE_PORT=8081
|
||||
CRASHES_FE_PORT=8082
|
||||
BUILD_FE_PORT=8083
|
||||
|
||||
# Internal app creds (local dev defaults)
|
||||
MARIADB_ROOT_PASSWORD=androidcast_root
|
||||
|
||||
@@ -7,10 +7,13 @@ ENV_EXAMPLE="$ROOT_DIR/.env.example"
|
||||
RUNTIME_DIR="$ROOT_DIR/runtime"
|
||||
DB_INIT_DIR="$RUNTIME_DIR/db-init"
|
||||
CRASH_CONFIG="$RUNTIME_DIR/crash-config.php"
|
||||
BUILD_CONFIG="$RUNTIME_DIR/build-config.php"
|
||||
OTA_DIR="$RUNTIME_DIR/ota-artifacts"
|
||||
|
||||
SRC_SCHEMA="$ROOT_DIR/../examples/crash_reporter/backend/sql/schema.mariadb.sql"
|
||||
SRC_MIG_004="$ROOT_DIR/../examples/crash_reporter/backend/sql/migrations/004_ticket_workflow.sql"
|
||||
SRC_MIG_005="$ROOT_DIR/../examples/crash_reporter/backend/sql/migrations/005_ticket_attachments.sql"
|
||||
SRC_MIG_060="$ROOT_DIR/runtime/db-init/060_build_ecosystem.sql"
|
||||
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
echo "docker not found in PATH"
|
||||
@@ -32,13 +35,15 @@ set -a
|
||||
source "$ENV_FILE"
|
||||
set +a
|
||||
|
||||
mkdir -p "$DB_INIT_DIR"
|
||||
mkdir -p "$DB_INIT_DIR" "$OTA_DIR"
|
||||
|
||||
cat >"$CRASH_CONFIG" <<EOF
|
||||
<?php
|
||||
return [
|
||||
'app_name' => 'Android Cast Crashes',
|
||||
'base_path' => '/app/androidcast_project/crashes',
|
||||
'session_name' => 'ac_crash_sess',
|
||||
'session_cookie_path' => '/app/androidcast_project',
|
||||
'db' => [
|
||||
'driver' => 'mysql',
|
||||
'sqlite_path' => __DIR__ . '/../data/crashes.sqlite',
|
||||
@@ -52,7 +57,6 @@ return [
|
||||
'charset' => 'utf8mb4',
|
||||
],
|
||||
],
|
||||
'session_name' => 'ac_crash_sess',
|
||||
'debug' => true,
|
||||
'rbac' => [
|
||||
'default_company_slug' => 'default',
|
||||
@@ -61,6 +65,51 @@ return [
|
||||
];
|
||||
EOF
|
||||
|
||||
cat >"$BUILD_CONFIG" <<EOF
|
||||
<?php
|
||||
return [
|
||||
'app_name' => 'Android Cast Builder',
|
||||
'base_path' => '/app/androidcast_project/build',
|
||||
'session_name' => 'ac_crash_sess',
|
||||
'session_cookie_path' => '/app/androidcast_project',
|
||||
'db' => [
|
||||
'driver' => 'mysql',
|
||||
'sqlite_path' => __DIR__ . '/../../crash_reporter/backend/data/crashes.sqlite',
|
||||
'mysql' => [
|
||||
'host' => 'mariadb',
|
||||
'port' => 3306,
|
||||
'socket' => '',
|
||||
'database' => '${MARIADB_DATABASE}',
|
||||
'username' => '${MARIADB_USER}',
|
||||
'password' => '${MARIADB_PASSWORD}',
|
||||
'charset' => 'utf8mb4',
|
||||
],
|
||||
],
|
||||
'debug' => true,
|
||||
'rbac' => [
|
||||
'default_company_slug' => 'default',
|
||||
'default_company_id' => 1,
|
||||
],
|
||||
'build' => [
|
||||
'docker_image' => 'androidcast-ci:latest',
|
||||
'ci_version' => '00.01.00.1000',
|
||||
'repo_root' => '/workspace',
|
||||
'artifacts_root' => '/workspace/out/builds',
|
||||
'ota_mount' => '/workspace/orchestration/runtime/ota-artifacts',
|
||||
'ota_base_url' => '${PUBLIC_BASE_URL}',
|
||||
'runner_script' => '/workspace/scripts/docker-build-runner.sh',
|
||||
'pipeline_config' => '/workspace/build.config.yml',
|
||||
'default_channels' => ['stable', 'staging', 'dev', 'nightly'],
|
||||
],
|
||||
'links' => [
|
||||
'hub' => '/app/androidcast_project/',
|
||||
'crashes' => '/app/androidcast_project/crashes/',
|
||||
'git' => '/app/androidcast_project/git/',
|
||||
'tickets' => '/app/androidcast_project/crashes/?view=tickets',
|
||||
],
|
||||
];
|
||||
EOF
|
||||
|
||||
cp "$SRC_SCHEMA" "$DB_INIT_DIR/010_schema.sql"
|
||||
{
|
||||
echo "USE \`${MARIADB_DATABASE}\`;"
|
||||
@@ -70,9 +119,13 @@ cp "$SRC_SCHEMA" "$DB_INIT_DIR/010_schema.sql"
|
||||
echo "USE \`${MARIADB_DATABASE}\`;"
|
||||
cat "$SRC_MIG_005"
|
||||
} >"$DB_INIT_DIR/050_ticket_attachments.sql"
|
||||
{
|
||||
echo "USE \`${MARIADB_DATABASE}\`;"
|
||||
cat "$SRC_MIG_060"
|
||||
} >"$DB_INIT_DIR/060_build_ecosystem.sql"
|
||||
|
||||
echo "Pulling images..."
|
||||
docker compose -f "$ROOT_DIR/docker-compose.yml" pull landing-fe gitea-fe crashes-fe mariadb gitea || true
|
||||
docker compose -f "$ROOT_DIR/docker-compose.yml" pull landing-fe gitea-fe crashes-fe build-fe mariadb gitea || true
|
||||
|
||||
echo "Starting/updating stack..."
|
||||
docker compose -f "$ROOT_DIR/docker-compose.yml" up -d --build --remove-orphans --force-recreate
|
||||
@@ -82,5 +135,7 @@ echo "Stack is up."
|
||||
echo "Landing: ${PUBLIC_BASE_URL}/app/androidcast_project/"
|
||||
echo "Gitea (direct FE): http://localhost:${GITEA_FE_PORT}/app/androidcast_project/git/"
|
||||
echo "Crashes (direct FE): http://localhost:${CRASHES_FE_PORT}/app/androidcast_project/crashes/"
|
||||
echo "Builder (direct FE): http://localhost:${BUILD_FE_PORT:-8083}/app/androidcast_project/build/"
|
||||
echo "Shared login: same user/password as Crashes (session cookie path /app/androidcast_project)"
|
||||
echo
|
||||
docker compose -f "$ROOT_DIR/docker-compose.yml" ps
|
||||
|
||||
@@ -4,6 +4,7 @@ services:
|
||||
depends_on:
|
||||
- gitea-fe
|
||||
- crashes-fe
|
||||
- build-fe
|
||||
ports:
|
||||
- "${LANDING_HTTP_PORT}:8080"
|
||||
volumes:
|
||||
@@ -38,6 +39,34 @@ services:
|
||||
- appnet
|
||||
restart: unless-stopped
|
||||
|
||||
build-fe:
|
||||
image: nginx:1.27-alpine
|
||||
depends_on:
|
||||
- build-php
|
||||
ports:
|
||||
- "${BUILD_FE_PORT}:8080"
|
||||
volumes:
|
||||
- ../:/workspace
|
||||
- ./nginx/build-fe.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
networks:
|
||||
- appnet
|
||||
restart: unless-stopped
|
||||
|
||||
build-php:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: images/build-php-fpm/Dockerfile
|
||||
depends_on:
|
||||
- mariadb
|
||||
volumes:
|
||||
- ../:/workspace
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- ./runtime/build-config.php:/workspace/examples/build_console/backend/config/config.php
|
||||
- ./runtime/ota-artifacts:/workspace/orchestration/runtime/ota-artifacts
|
||||
networks:
|
||||
- appnet
|
||||
restart: unless-stopped
|
||||
|
||||
crash-php:
|
||||
build:
|
||||
context: .
|
||||
|
||||
7
orchestration/images/build-php-fpm/Dockerfile
Normal file
7
orchestration/images/build-php-fpm/Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
FROM php:8.2-fpm-alpine
|
||||
|
||||
RUN apk add --no-cache bash docker-cli icu-dev libzip-dev oniguruma-dev mariadb-client sqlite-dev \
|
||||
&& docker-php-ext-install pdo pdo_mysql pdo_sqlite \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
WORKDIR /workspace/examples/build_console/backend
|
||||
39
orchestration/nginx/build-fe.conf
Normal file
39
orchestration/nginx/build-fe.conf
Normal file
@@ -0,0 +1,39 @@
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
|
||||
client_max_body_size 64m;
|
||||
index index.php;
|
||||
|
||||
location = / {
|
||||
return 302 /app/androidcast_project/build/;
|
||||
}
|
||||
|
||||
location /app/androidcast_project/build/ {
|
||||
alias /workspace/examples/build_console/backend/public/;
|
||||
index index.php;
|
||||
try_files $uri $uri/ @build_front;
|
||||
}
|
||||
|
||||
location /app/androidcast_project/crashes/assets/ {
|
||||
alias /workspace/examples/crash_reporter/backend/public/assets/;
|
||||
}
|
||||
|
||||
location @build_front {
|
||||
rewrite ^ /app/androidcast_project/build/index.php?$query_string last;
|
||||
}
|
||||
|
||||
location ~ ^/app/androidcast_project/build/(.+\.php)$ {
|
||||
alias /workspace/examples/build_console/backend/public/$1;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME /workspace/examples/build_console/backend/public/$1;
|
||||
fastcgi_param SCRIPT_NAME /app/androidcast_project/build/$1;
|
||||
fastcgi_param DOCUMENT_ROOT /workspace/examples/build_console/backend/public;
|
||||
fastcgi_pass build-php:9000;
|
||||
fastcgi_read_timeout 300s;
|
||||
}
|
||||
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,20 @@ server {
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location /app/androidcast_project/build/ {
|
||||
proxy_pass http://build-fe:8080;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location /app/androidcast_project/v0/ota/ {
|
||||
alias /workspace/orchestration/runtime/ota-artifacts/v0/;
|
||||
add_header Cache-Control "public, max-age=60";
|
||||
}
|
||||
|
||||
location /app/androidcast_project/ {
|
||||
alias /workspace/examples/app_hub/;
|
||||
index index.html;
|
||||
|
||||
30
orchestration/runtime/db-init/060_build_ecosystem.sql
Normal file
30
orchestration/runtime/db-init/060_build_ecosystem.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
CREATE TABLE IF NOT EXISTS builds (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
build_code VARCHAR(64) NOT NULL,
|
||||
status ENUM('queued','running','passed','failed','cancelled') NOT NULL DEFAULT 'queued',
|
||||
phase VARCHAR(64) NOT NULL DEFAULT 'init',
|
||||
git_ref VARCHAR(256) NULL,
|
||||
git_sha VARCHAR(64) NULL,
|
||||
branch VARCHAR(128) NULL,
|
||||
pipeline_yaml LONGTEXT NULL,
|
||||
params_json LONGTEXT NOT NULL,
|
||||
dockerfile_version VARCHAR(32) NOT NULL DEFAULT '00.01.00.1000',
|
||||
builder_id VARCHAR(128) NOT NULL DEFAULT 'local-docker',
|
||||
version_app VARCHAR(32) NULL,
|
||||
version_code INT NULL,
|
||||
target_os VARCHAR(32) NOT NULL DEFAULT 'android',
|
||||
min_api_level INT NOT NULL DEFAULT 24,
|
||||
ota_channel VARCHAR(64) NULL,
|
||||
auto_ota TINYINT(1) NOT NULL DEFAULT 0,
|
||||
auto_deploy TINYINT(1) NOT NULL DEFAULT 0,
|
||||
log_path VARCHAR(512) NULL,
|
||||
artifacts_json LONGTEXT NULL,
|
||||
error_message VARCHAR(512) NULL,
|
||||
created_by_user_id INT UNSIGNED NULL,
|
||||
started_at TIMESTAMP NULL,
|
||||
finished_at TIMESTAMP NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE KEY uq_builds_code (build_code),
|
||||
KEY idx_builds_status (status),
|
||||
KEY idx_builds_created (created_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
Reference in New Issue
Block a user