Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make all game assets self-hostable #169

Closed
bgstack15 opened this issue Jul 26, 2023 · 2 comments
Closed

make all game assets self-hostable #169

bgstack15 opened this issue Jul 26, 2023 · 2 comments
Labels
feature Additional functionality that might require some significant work

Comments

@bgstack15
Copy link
Contributor

I noticed that the web browser makes requests to fonts.googleapis.com and unpkg.com for stylesheets. Would it be possible to add a flag that uses some cached version that can be included in the docker image, so this game does not send users to these urls?

@joffrey-bion
Copy link
Owner

joffrey-bion commented Jul 26, 2023

Thanks for the idea! I think I could actually vendor those in. Like download them and host them as part of the docker image. I will think of something when dealing with the forward header for reverse proxies.

@bgstack15
Copy link
Contributor Author

bgstack15 commented Jul 26, 2023

I have the world's tenth-most-ugliest process ever devised for getting around this. I'm sure whatever you come up with will be more logical and simpler.

Step by step

I fetched all non-local urls with browser developer tools.

steps taken

cd /var/www/seven-wonders-assets/
wget 'https://fonts.googleapis.com/css2?family=Acme&display=swap'
# modify css2?f* to use url /seven-wonders-assets/
wget 'https://fonts.gstatic.com/s/acme/v21/RrQfboBx-C5_bx0.ttf'
wget 'https://unpkg.com/normalize.css@%5E7.0.0'
wget 'https://unpkg.com/@blueprintjs/icons@%5E4.13.0/lib/css/blueprint-icons.css'
wget 'https://unpkg.com/@blueprintjs/core@%5E4.15.0/lib/css/blueprint.css'

I found app.jar with sudo ls -al /var/lib/docker/overlay2/*/*/app.jar and finding the exact filesize one that matched from docker exec -it seven_wonders ls -al /app.jar.

get app.jar from sudo cp -pi /var/lib/docker/overlay2/l/JTQPGSF4VGTC4UPZ4W2Y7JUOXI/app.jar ~/foo
and with openjdk 17 installed, run:

cd ~/foo
jar xvf app.jar
vi BOOT-INF/classes/static/index.html

and modify it to use /seven-wonders-assets/ paths for all the files. I set css2 to just "css2" and renamed the file to omit the question mark and other parameter-type entries. Its whole contents are as follows.

<!doctype html>
<html lang="en">
 <head>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1">

   <!-- The .ico is for compatibliity with Safari, which doesn't support SVG -->
   <link rel="icon" href="./favicon.ico" sizes="48x48">
   <link rel="icon" href="./favicon.svg" sizes="any" type="image/svg+xml">

   <title>Seven Wonders</title>
   <link href='/seven-wonders-assets/css2' rel='stylesheet'>
   <!-- Style dependencies -->
   <link href="/seven-wonders-assets/normalize.css@^7.0.0" rel="stylesheet"/>
   <!-- Blueprint stylesheets -->
   <link href="/seven-wonders-assets/blueprint-icons.css" rel="stylesheet"/>
   <link href="/seven-wonders-assets/blueprint.css" rel="stylesheet"/>
 </head>
 <body>
   <div id="root"></div>
   <script src="sw-ui.js"></script>
 </body>
</html>

And now upload the updated file into app.jar

jar -uf app.jar BOOT-INF/classes/static/index.html

And send that file back to where it came from.

sudo cp -pi ~/foo/app.jar /var/lib/docker/overlay2/l/JTQPGSF4VGTC4UPZ4W2Y7JUOXI/app.jar

And restart my docker app, which is a systemd service.

time sudo systemctl restart seven-wonders

And confirm the jar is still updated.

docker exec -it seven_wonders ls -al /app.jar

And now this game works without leaking info to the font and unpkg servers.

@joffrey-bion joffrey-bion added the feature Additional functionality that might require some significant work label Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Additional functionality that might require some significant work
Projects
None yet
Development

No branches or pull requests

2 participants