Blame
|
1 | # Flash-Container |
||||||
| 2 | ||||||||
| 3 | ||||||||
| 4 | # FlashContainer: Host & Serve Flash (.swf) Files with Ruffle |
|||||||
| 5 | ||||||||
| 6 | **FlashContainer** is a lightweight container designed to host and serve Flash `.swf` files using the Ruffle emulator. This allows you to easily run and view Flash-based content in a modern browser, even after Flash's official deprecation. |
|||||||
| 7 | ||||||||
| 8 | ## How It Works |
|||||||
| 9 | ||||||||
| 10 | This container runs a web server using Node.js and serves `.swf` files via the [Ruffle](https://ruffle.rs/) emulator, which is a Flash Player emulator written in Rust. The emulator provides a modern way to play old Flash content by converting it to formats supported by current browsers. |
|||||||
| 11 | ||||||||
| 12 | - **Ruffle Integration**: The container downloads the latest nightly release of Ruffle, ensuring up-to-date compatibility with `.swf` files. |
|||||||
| 13 | - **http-server**: This serves the content via HTTP, exposing it on port 80. |
|||||||
| 14 | - **External SWF File**: You can map your own `.swf` files via Docker volume, making it easy to change content without modifying the image itself. |
|||||||
| 15 | ||||||||
| 16 | ## Usage |
|||||||
| 17 | ||||||||
| 18 | 1. **Pull the Image** |
|||||||
| 19 | ```bash |
|||||||
| 20 | docker pull tebwritescode/flashcontainer |
|||||||
| 21 | ``` |
|||||||
| 22 | ||||||||
| 23 | 2. **Run the Container** |
|||||||
| 24 | ||||||||
| 25 | Mount your `.swf` file into the container with a volume mapping: |
|||||||
| 26 | ||||||||
| 27 | ```bash |
|||||||
| 28 | docker run -d -p 80:80 -v /path/to/your/game.swf:/app/game.swf tebwritescode/flashcontainer |
|||||||
| 29 | ``` |
|||||||
| 30 | ||||||||
| 31 | - `/path/to/your/game.swf` should be replaced with the path to your local `.swf` file. |
|||||||
| 32 | - The container will serve your `.swf` file at `http://localhost`. |
|||||||
| 33 | ||||||||
| 34 | 3. **Access the Website** |
|||||||
| 35 | ||||||||
| 36 | Open a browser and navigate to `http://localhost` (or the IP where your container is hosted) to view and interact with your Flash file. |
|||||||
| 37 | ||||||||
| 38 | ## Features |
|||||||
| 39 | ||||||||
| 40 | - **Serve Flash Content Easily**: Simple setup for serving `.swf` files. |
|||||||
| 41 | - **Ruffle Emulator**: Play Flash content in a browser without needing Flash Player. |
|||||||
| 42 | - **Volume Mapping**: No need to modify the container—just swap out the `.swf` file. |
|||||||
| 43 | - **Lightweight**: Minimal image size using Node.js and Ruffle. |
|||||||
| 44 | ||||||||
| 45 | ## Customization |
|||||||
| 46 | ||||||||
| 47 | - You can modify the HTML file that hosts the `.swf` content by editing `index.html` and adjusting the Ruffle embed configurations. |
|||||||
| 48 | - Use different `.swf` files by swapping the file you mount to `/app/game.swf`. |
|||||||
| 49 | ||||||||
| 50 | ## Requirements |
|||||||
| 51 | ||||||||
| 52 | - Docker installed on your host machine. |
|||||||
| 53 | - A valid `.swf` file to be served. |
|||||||
| 54 | ||||||||
| 55 | ## Screenshots |
|||||||
| 56 |  |
|||||||
| 57 | ||||||||
| 58 |  |
|||||||
| 59 | ||||||||
| 60 |  |
|||||||
| 61 | ||||||||
| 62 | --- |
|||||||
| 63 | ## Source |
|||||||
| 64 | Dockerfile |
|||||||
| 65 | ||||||||
| 66 | ``` |
|||||||
| 67 | # Base image with Node.js and http-server to serve files |
|||||||
| 68 | FROM node:20-bullseye |
|||||||
| 69 | ||||||||
| 70 | # Install http-server globally to serve files |
|||||||
| 71 | RUN npm install -g http-server |
|||||||
| 72 | ||||||||
| 73 | # Set working directory |
|||||||
| 74 | WORKDIR /app |
|||||||
| 75 | ||||||||
| 76 | # Download the specified nightly release of the Ruffle self-hosted package |
|||||||
| 77 | # Install additional dependencies: Java, Git |
|||||||
| 78 | RUN apt-get update && apt-get install -y \ |
|||||||
| 79 | default-jdk \ |
|||||||
| 80 | maven \ |
|||||||
| 81 | git \ |
|||||||
| 82 | default-mysql-client \ |
|||||||
| 83 | libasound2-dev \ |
|||||||
| 84 | libxcb-shape0-dev \ |
|||||||
| 85 | libxcb-xfixes0-dev \ |
|||||||
| 86 | libgtk-3-dev \ |
|||||||
| 87 | libudev-dev \ |
|||||||
| 88 | libxcb-xinput-dev \ |
|||||||
| 89 | libxcb-xkb-dev \ |
|||||||
| 90 | libxcb-cursor-dev \ |
|||||||
| 91 | default-jre-headless \ |
|||||||
| 92 | cmake \ |
|||||||
| 93 | g++ \ |
|||||||
| 94 | unzip \ |
|||||||
| 95 | wget \ |
|||||||
| 96 | && apt-get clean \ |
|||||||
| 97 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ |
|||||||
| 98 | . "$HOME/.cargo/env" |
|||||||
| 99 | ||||||||
| 100 | # Install curl and jq to fetch the latest Ruffle nightly release |
|||||||
| 101 | RUN apt-get update && apt-get install -y curl jq |
|||||||
| 102 | ||||||||
| 103 | # Download the latest nightly release of Ruffle |
|||||||
| 104 | RUN LATEST_RELEASE_URL=$(curl -s https://api.github.com/repos/ruffle-rs/ruffle/releases | jq -r '.[] | select(.prerelease == true) | .assets[].browser_download_url | select(contains("web-selfhosted.zip"))' | head -n 1) && \ |
|||||||
| 105 | wget $LATEST_RELEASE_URL -O /tmp/ruffle-nightly.zip && \ |
|||||||
| 106 | mkdir -p /app/ruffle && \ |
|||||||
| 107 | unzip /tmp/ruffle-nightly.zip -d /app/ruffle && \ |
|||||||
| 108 | rm /tmp/ruffle-nightly.zip |
|||||||
| 109 | ||||||||
| 110 | # Take out the trash |
|||||||
| 111 | RUN rm -rf ./ruffle-nightly-2024_10_13-web-selfhosted.zip |
|||||||
| 112 | ||||||||
| 113 | # Copy the local HTML file into the container |
|||||||
| 114 | COPY ./index.html /app/index.html |
|||||||
| 115 | ||||||||
| 116 | # Copy the local game file into the container |
|||||||
| 117 | #COPY ./game.swf /app/game.swf |
|||||||
| 118 | ||||||||
| 119 | # Expose port 80 for serving the SWF game |
|||||||
| 120 | EXPOSE 80 |
|||||||
| 121 | ||||||||
| 122 | # Command to serve the game using http-server |
|||||||
| 123 | CMD ["http-server", ".", "-p", "80"] |
|||||||
| 124 | ``` |
|||||||
| 125 | ||||||||
| 126 | index.html |
|||||||
| 127 | ||||||||
| 128 | ``` |
|||||||
| 129 | <!DOCTYPE html> |
|||||||
| 130 | <html lang="en"> |
|||||||
| 131 | <head> |
|||||||
| 132 | <meta charset="UTF-8"> |
|||||||
| 133 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|||||||
| 134 | <script src="ruffle/ruffle.js"></script> |
|||||||
| 135 | <style> |
|||||||
| 136 | html, body { |
|||||||
| 137 | margin: 0; |
|||||||
| 138 | padding: 0; |
|||||||
| 139 | width: 100%; |
|||||||
| 140 | height: 100%; |
|||||||
| 141 | } |
|||||||
| 142 | ||||||||
| 143 | #ruffle-player { |
|||||||
| 144 | width: 100%; |
|||||||
| 145 | height: 100%; |
|||||||
| 146 | } |
|||||||
| 147 | </style> |
|||||||
| 148 | </head> |
|||||||
| 149 | <body> |
|||||||
| 150 | <script> |
|||||||
| 151 | window.RufflePlayer = window.RufflePlayer || {}; |
|||||||
| 152 | ||||||||
| 153 | window.RufflePlayer.config = { |
|||||||
| 154 | "letterbox": "on", |
|||||||
| 155 | } |
|||||||
| 156 | ||||||||
| 157 | window.addEventListener("DOMContentLoaded", () => { |
|||||||
| 158 | let ruffle = window.RufflePlayer.newest(); |
|||||||
| 159 | let player = ruffle.createPlayer(); |
|||||||
| 160 | player.style.width = "100%"; // Set player's width to 100% |
|||||||
| 161 | player.style.height = "100%"; // Set player's height to 100% |
|||||||
| 162 | document.body.appendChild(player); |
|||||||
| 163 | player.load("game.swf"); // Load the local SWF file named game.swf |
|||||||
| 164 | }); |
|||||||
| 165 | </script> |
|||||||
| 166 | </body> |
|||||||
| 167 | </html> |
|||||||
| 168 | ``` |
|||||||
| 169 | --- |
|||||||
| 170 | ||||||||
| 171 | ||||||||
| 172 | ||||||||
| 173 | By using **FlashContainer**, you can keep your favorite Flash content alive and playable through modern web technologies. |
|||||||