Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Seven Wonders docker image: use local css and fonts

Overview

I hacked the seven-wonders docker image to not use external (and potentially-tracking) servers for font and stylesheet assets.

I opened up an issue upstream to see if this is something fixable during the build process to avoid this silliness.

Step by step

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

steps taken

These are the steps taken to set up the seven-wonders docker image to use local assets and not leak personal info.

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.

Comments