M .gitignore => .gitignore +3 -1
@@ 6,4 6,6 @@ assets/svg/*.png
build.ninja
.ninja_log
api/config.toml
-api/.env>
\ No newline at end of file
+api/.env
+assets/dist
+assets/final<
\ No newline at end of file
A docker/nginx.conf => docker/nginx.conf +44 -0
@@ 0,0 1,44 @@
+# This is the nginx config that we (starkingdoms) use in production.
+# To use this for yourself, replace `YOURDOMAIN` with your domain (ie: starkingdoms.io, bleeding.starkingdoms.io, etc)
+# and replace YOURSERVERIP with the IP that the server is hosted on (for local, use 127.0.0.1)
+# Ports are the same as the ones deployed by the scripts in /ansible/.
+# You can use this as a guide to write your own config. Be aware that the game will not function very well if there is
+# high CPU usage on the proxy server, as nginx will struggle to proxy the websocket connection.
+# Put this on an at-least-semi-decent server.
+# Game pings, game stream and static assets are on the primary domain (ex: bleeding.starkingdoms.io)
+server {
+ server_name YOURDOMAIN;
+
+ # Static assets should be routed to the nginx container which can handle the traffic
+ location / {
+ proxy_set_header Host $host; # Very important (security, logins will break without this), do not remove
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_pass http://YOURSERVERIP:3206; # Web port is 3206 with the provided ansible files
+ }
+
+ # Websockets should be upgraded and forwarded to the game server
+ location /ws {
+ proxy_set_header Host $host;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_http_version 1.1;
+ proxy_set_header Connection "Upgrade";
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_pass http://YOURSERVERIP:3204; # Game server is 3204 with the provided ansible files
+ }
+ # Pings to the game server should be routed there too
+ location /ping {
+ proxy_set_header Host $host;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_pass http://YOURSERVERIP:3204;
+ }
+}
+# API is on a secondary domain (api.bleeding.starkingdoms.io)
+server {
+ server_name api.YOURDOMAIN.COM;
+
+ location / {
+ proxy_set_header Host $host; # Very important (security), do not remove
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Very important (security), do not remove
+ proxy_pass http://YOURSERVERIP:3205; # API server is 3205 with the provided ansible files
+ }
+}<
\ No newline at end of file
M spacetime_rs/src/commands/client.rs => spacetime_rs/src/commands/client.rs +6 -0
@@ 27,6 27,12 @@ pub fn client_protobuf(_: Vec<String>, root: PathBuf) -> Result<(), Box<dyn Erro
}
pub fn build_client_prod(_: Vec<String>, root: PathBuf) -> Result<(), Box<dyn Error>> {
+ let mut config_file_writer = create_writer(&root)?;
+
+ configure_client(&mut config_file_writer, &root)?;
+
+ exec_ninja(&root, vec!["asset".to_string()])?;
+
exec("yarn", &root.join("client"), vec![])?;
exec("yarn", &root.join("client"), vec!["build".to_string()])
}
M spacetime_rs/src/commands/docker.rs => spacetime_rs/src/commands/docker.rs +0 -7
@@ 16,13 16,6 @@ fn _build(img: &str, channel: &str, root: &PathBuf) -> Result<(), Box<dyn Error>
} else if img == "api" {
build_api_prod(vec![], root.clone())?;
} else if img == "web" {
- // we need to swap out the urls
- // TODO
- // for now i am just adding all three to all clients
-
- // "s/let api_server = \"http:\\/\\/localhost:8080\";/let api_server = \"https:\\/\\/api.${1}.${2}\";/" "$SCRIPT_DIR/client/index.html"
- // "s/let servers = \[\"localhost:3000\"\];/let servers = [\"${1}.${2}\"];/" "$SCRIPT_DIR/client/index.html"
-
let (a, b) = match channel {
"stable" => ("starkingdoms", "tk"),
_ => (channel, "starkingdoms.io")