feat(apps): add saleor storefront
This commit is contained in:
@@ -244,6 +244,8 @@ async fn repair_saleor_network_aliases() {
|
||||
("saleor-api", "api"),
|
||||
("saleor-worker", "worker"),
|
||||
("saleor", "saleor"),
|
||||
("saleor-storefront", "storefront"),
|
||||
("saleor-storefront-app", "storefront-app"),
|
||||
] {
|
||||
let exists = tokio::process::Command::new("podman")
|
||||
.args(["container", "exists", container])
|
||||
@@ -446,6 +448,9 @@ const NETBIRD_SERVER_IMAGE: &str = "docker.io/netbirdio/netbird-server:0.71.2";
|
||||
const NETBIRD_PROXY_IMAGE: &str = "docker.io/library/nginx:1.27-alpine";
|
||||
const SALEOR_API_IMAGE: &str = "ghcr.io/saleor/saleor:3.23";
|
||||
const SALEOR_DASHBOARD_IMAGE: &str = "ghcr.io/saleor/saleor-dashboard:3.23";
|
||||
const SALEOR_STOREFRONT_IMAGE: &str = "localhost/archipelago/saleor-storefront:6eb0b97";
|
||||
const SALEOR_STOREFRONT_CONTEXT: &str =
|
||||
"https://github.com/saleor/storefront.git#6eb0b97b25bd4344d8139515a1cabf763d703b39";
|
||||
const SALEOR_POSTGRES_IMAGE: &str = "docker.io/library/postgres:15-alpine";
|
||||
const SALEOR_VALKEY_IMAGE: &str = "docker.io/valkey/valkey:8.1-alpine";
|
||||
const SALEOR_JAEGER_IMAGE: &str = "docker.io/jaegertracing/jaeger:latest";
|
||||
@@ -1656,6 +1661,8 @@ impl RpcHandler {
|
||||
"saleor-api",
|
||||
"saleor-worker",
|
||||
"saleor",
|
||||
"saleor-storefront",
|
||||
"saleor-storefront-app",
|
||||
],
|
||||
)
|
||||
.await?
|
||||
@@ -1663,7 +1670,7 @@ impl RpcHandler {
|
||||
return Ok(adopted);
|
||||
}
|
||||
|
||||
install_log("INSTALL START: saleor stack (postgres + valkey + api + worker + dashboard)")
|
||||
install_log("INSTALL START: saleor stack (postgres + valkey + api + worker + dashboard + storefront)")
|
||||
.await;
|
||||
info!("Installing Saleor stack");
|
||||
|
||||
@@ -1692,6 +1699,8 @@ impl RpcHandler {
|
||||
"saleor",
|
||||
"saleor-api",
|
||||
"saleor-worker",
|
||||
"saleor-storefront",
|
||||
"saleor-storefront-app",
|
||||
"saleor-db",
|
||||
"saleor-cache",
|
||||
"saleor-jaeger",
|
||||
@@ -1717,6 +1726,7 @@ impl RpcHandler {
|
||||
"/var/lib/archipelago/saleor",
|
||||
"/var/lib/archipelago/saleor-db",
|
||||
"/var/lib/archipelago/saleor-cache",
|
||||
"/var/lib/archipelago/saleor-storefront",
|
||||
])
|
||||
.output()
|
||||
.await;
|
||||
@@ -1725,6 +1735,7 @@ impl RpcHandler {
|
||||
"/var/lib/archipelago/saleor",
|
||||
"/var/lib/archipelago/saleor-db",
|
||||
"/var/lib/archipelago/saleor-cache",
|
||||
"/var/lib/archipelago/saleor-storefront",
|
||||
] {
|
||||
let _ = tokio::process::Command::new("sudo")
|
||||
.args(["chown", "-R", &format!("{}:{}", user, user), dir])
|
||||
@@ -1744,10 +1755,12 @@ impl RpcHandler {
|
||||
let dashboard_origin = format!("http://{}:9010", host_ip);
|
||||
let dashboard_url = format!("{}/", dashboard_origin);
|
||||
let api_url = format!("http://{}:8000/graphql/", host_ip);
|
||||
let internal_api_url = "http://api:8000/graphql/";
|
||||
let storefront_origin = format!("http://{}:9011", host_ip);
|
||||
let allowed_hosts = format!("localhost,127.0.0.1,api,saleor-api,{}", host_ip);
|
||||
let allowed_client_hosts = format!(
|
||||
"{},http://localhost:9010,http://127.0.0.1:9010",
|
||||
dashboard_origin
|
||||
"{},{},http://localhost:9010,http://127.0.0.1:9010,http://localhost:9011,http://127.0.0.1:9011",
|
||||
dashboard_origin, storefront_origin
|
||||
);
|
||||
let database_url = format!("postgres://saleor:{}@db/saleor", db_pass);
|
||||
|
||||
@@ -2067,6 +2080,90 @@ user.save()
|
||||
]);
|
||||
run_required_stack_command("saleor", "create dashboard", &mut dashboard_cmd).await?;
|
||||
|
||||
let mut storefront_build_cmd = tokio::process::Command::new("podman");
|
||||
storefront_build_cmd.args([
|
||||
"build",
|
||||
"--network",
|
||||
"saleor-net",
|
||||
"--pull=always",
|
||||
"-t",
|
||||
SALEOR_STOREFRONT_IMAGE,
|
||||
"--build-arg",
|
||||
&format!("NEXT_PUBLIC_SALEOR_API_URL={}", internal_api_url),
|
||||
"--build-arg",
|
||||
&format!("NEXT_PUBLIC_STOREFRONT_URL={}", storefront_origin),
|
||||
"--build-arg",
|
||||
"NEXT_PUBLIC_DEFAULT_CHANNEL=default-channel",
|
||||
SALEOR_STOREFRONT_CONTEXT,
|
||||
]);
|
||||
run_required_stack_command("saleor", "build storefront", &mut storefront_build_cmd)
|
||||
.await?;
|
||||
|
||||
let mut storefront_cmd = tokio::process::Command::new("podman");
|
||||
storefront_cmd.args([
|
||||
"run",
|
||||
"-d",
|
||||
"--name",
|
||||
"saleor-storefront-app",
|
||||
"--network",
|
||||
"saleor-net",
|
||||
"--network-alias",
|
||||
"storefront-app",
|
||||
"--restart=unless-stopped",
|
||||
"--cap-drop=ALL",
|
||||
"--cap-add=CHOWN",
|
||||
"--cap-add=DAC_OVERRIDE",
|
||||
"--cap-add=FOWNER",
|
||||
"--cap-add=SETGID",
|
||||
"--cap-add=SETUID",
|
||||
"--security-opt=no-new-privileges:true",
|
||||
"--memory=512m",
|
||||
"--pids-limit=2048",
|
||||
"-e",
|
||||
&format!("NEXT_PUBLIC_SALEOR_API_URL={}", internal_api_url),
|
||||
"-e",
|
||||
&format!("NEXT_PUBLIC_STOREFRONT_URL={}", storefront_origin),
|
||||
"-e",
|
||||
"NEXT_PUBLIC_DEFAULT_CHANNEL=default-channel",
|
||||
SALEOR_STOREFRONT_IMAGE,
|
||||
]);
|
||||
run_required_stack_command("saleor", "create storefront app", &mut storefront_cmd).await?;
|
||||
|
||||
write_saleor_storefront_proxy_config().await?;
|
||||
let mut storefront_proxy_cmd = tokio::process::Command::new("podman");
|
||||
storefront_proxy_cmd.args([
|
||||
"run",
|
||||
"-d",
|
||||
"--name",
|
||||
"saleor-storefront",
|
||||
"--network",
|
||||
"saleor-net",
|
||||
"--network-alias",
|
||||
"storefront",
|
||||
"--restart=unless-stopped",
|
||||
"--cap-drop=ALL",
|
||||
"--cap-add=CHOWN",
|
||||
"--cap-add=DAC_OVERRIDE",
|
||||
"--cap-add=FOWNER",
|
||||
"--cap-add=NET_BIND_SERVICE",
|
||||
"--cap-add=SETGID",
|
||||
"--cap-add=SETUID",
|
||||
"--security-opt=no-new-privileges:true",
|
||||
"--memory=128m",
|
||||
"--pids-limit=1024",
|
||||
"-p",
|
||||
"9011:80",
|
||||
"-v",
|
||||
"/var/lib/archipelago/saleor-storefront/nginx.conf:/etc/nginx/conf.d/default.conf:ro",
|
||||
NETBIRD_PROXY_IMAGE,
|
||||
]);
|
||||
run_required_stack_command(
|
||||
"saleor",
|
||||
"create storefront proxy",
|
||||
&mut storefront_proxy_cmd,
|
||||
)
|
||||
.await?;
|
||||
|
||||
wait_for_stack_containers(
|
||||
"saleor",
|
||||
&[
|
||||
@@ -2077,6 +2174,8 @@ user.save()
|
||||
"saleor-api",
|
||||
"saleor-worker",
|
||||
"saleor",
|
||||
"saleor-storefront",
|
||||
"saleor-storefront-app",
|
||||
],
|
||||
120,
|
||||
)
|
||||
@@ -2092,6 +2191,8 @@ user.save()
|
||||
"saleor-api",
|
||||
"saleor-worker",
|
||||
"saleor",
|
||||
"saleor-storefront",
|
||||
"saleor-storefront-app",
|
||||
],
|
||||
30,
|
||||
)
|
||||
@@ -2109,7 +2210,7 @@ user.save()
|
||||
Ok(serde_json::json!({
|
||||
"success": true,
|
||||
"package_id": "saleor",
|
||||
"message": "Saleor stack installed (7 containers)",
|
||||
"message": "Saleor stack installed (9 containers)",
|
||||
}))
|
||||
}
|
||||
}
|
||||
@@ -2130,6 +2231,48 @@ async fn read_or_generate_b64_secret(name: &str) -> String {
|
||||
secret
|
||||
}
|
||||
|
||||
async fn write_saleor_storefront_proxy_config() -> Result<()> {
|
||||
tokio::fs::create_dir_all("/var/lib/archipelago/saleor-storefront")
|
||||
.await
|
||||
.context("Failed to create Saleor storefront config directory")?;
|
||||
|
||||
let nginx_conf = r#"server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
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 ^~ /graphql/ {
|
||||
proxy_pass http://api:8000/graphql/;
|
||||
proxy_set_header Host api;
|
||||
proxy_set_header Origin "";
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://storefront-app:3000;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Accept-Encoding "";
|
||||
sub_filter_once off;
|
||||
sub_filter_types text/html application/javascript text/javascript;
|
||||
sub_filter 'http://api:8000/graphql/' '$http_x_forwarded_proto://$host/graphql/';
|
||||
}
|
||||
}
|
||||
"#;
|
||||
|
||||
tokio::fs::write(
|
||||
"/var/lib/archipelago/saleor-storefront/nginx.conf",
|
||||
nginx_conf,
|
||||
)
|
||||
.await
|
||||
.context("Failed to write Saleor storefront nginx.conf")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn write_netbird_config_files(host_ip: &str) -> Result<()> {
|
||||
let public_origin = format!("http://{}:8087", host_ip);
|
||||
let server_origin = format!("http://{}:8086", host_ip);
|
||||
|
||||
@@ -69,6 +69,8 @@ impl DockerPackageScanner {
|
||||
"saleor-cache",
|
||||
"saleor-jaeger",
|
||||
"saleor-mailpit",
|
||||
"saleor-storefront",
|
||||
"saleor-storefront-app",
|
||||
"buildx_buildkit_default",
|
||||
];
|
||||
|
||||
@@ -519,7 +521,7 @@ fn get_app_metadata(app_id: &str) -> AppMetadata {
|
||||
},
|
||||
"saleor" => AppMetadata {
|
||||
title: "Saleor".to_string(),
|
||||
description: "Composable commerce platform with GraphQL API and dashboard. Log in with admin@example.com; the password is stored on the node at /var/lib/archipelago/secrets/saleor-admin-password".to_string(),
|
||||
description: "Composable commerce platform with storefront, dashboard, and GraphQL API. The customer storefront opens on port 9011; admin dashboard is on 9010 with admin@example.com credentials stored on the node.".to_string(),
|
||||
icon: "/assets/img/app-icons/saleor.svg".to_string(),
|
||||
repo: "https://github.com/saleor/saleor".to_string(),
|
||||
tier: "",
|
||||
|
||||
Reference in New Issue
Block a user