# How to Run This Game on Your Own Computer

This guide will walk you through running the Radoznalo Mače game on your own machine using Docker. You don't need to know anything about Docker or web servers — just follow the steps below.

---

## What is Docker?

Docker is a free tool that lets you run software in a self-contained "container." Think of it like a pre-packed box that contains everything the app needs to run — you don't have to install PHP, Apache, or configure anything yourself. Docker handles all of that for you.

---

## Step 1 — Install Docker

### On Windows or Mac
1. Go to **https://www.docker.com/products/docker-desktop**
2. Download and install **Docker Desktop**
3. Open Docker Desktop after it installs — you'll see a whale icon in your taskbar/menu bar
4. Wait until it says **"Docker is running"** (the whale icon stops animating)

### On Linux (Ubuntu/Debian)
Open a terminal and run these commands one at a time:

```bash
sudo apt update
sudo apt install -y docker.io docker-compose-plugin
sudo systemctl start docker
sudo systemctl enable docker
```

Then add yourself to the docker group so you don't need `sudo` every time:
```bash
sudo usermod -aG docker $USER
```
Log out and log back in for this to take effect.

---

## Step 2 — Get the Game Files

You need to have this project's folder on your computer. If you received it as a ZIP file:
1. Unzip it somewhere easy to find, like your Desktop
2. You should have a folder containing files like `index.html`, `game.js`, `Dockerfile`, etc.

If you're using Git:
```bash
git clone <repository-url>
cd biologija
```

---

## Step 3 — Open a Terminal in the Project Folder

### On Windows
1. Open the folder in File Explorer
2. Click in the address bar at the top, type `cmd`, and press Enter
3. A Command Prompt window will open already inside that folder

### On Mac
1. Open the folder in Finder
2. Right-click the folder and choose **"New Terminal at Folder"**
   - If you don't see this option: go to **System Settings → Privacy & Security → Full Disk Access** and enable Terminal, or right-click while holding Option

### On Linux
Right-click inside the folder and choose **"Open Terminal"** (or open a terminal and use `cd` to navigate to the folder).

---

## Step 4 — Start the Game

In the terminal window, type this command and press Enter:

```bash
docker compose up -d --build
```

What this does:
- **`docker compose`** — tells Docker to read the setup instructions from the `docker-compose.yml` file
- **`up`** — starts the app
- **`-d`** — runs it in the background (so you can close the terminal if you want)
- **`--build`** — builds the container image from the project files

The first time you run this it will take **1–3 minutes** because Docker needs to download the base image. You'll see a lot of text scroll by — that's normal. Wait until you see something like:

```
✔ Container biologija-web-1  Started
```

---

## Step 5 — Open the Game in Your Browser

Once the container is running, open your web browser and go to:

```
http://localhost:8080
```

The game should load. That's it — you're done!

---

## How to Stop the Game

When you want to shut it down, open a terminal in the project folder and run:

```bash
docker compose down
```

This stops the container but keeps all your question data saved for next time.

---

## How to Start It Again Later

Just run the same command again (no need for `--build` after the first time):

```bash
docker compose up -d
```

---

## Troubleshooting

### "docker: command not found" or "docker compose: command not found"
Docker is not installed or not running. Go back to Step 1.

### The browser shows "This site can't be reached" or "Connection refused"
- Make sure you typed `http://localhost:8080` exactly (not `https://`)
- Wait a few more seconds after running the start command and try again
- Run `docker compose ps` — if the container isn't listed as "running", run `docker compose up -d --build` again

### Port 8080 is already in use
Another app on your computer is using port 8080. Open `docker-compose.yml` in a text editor and change `"8080:80"` to `"8181:80"` (or any other number like 9090). Then go to `http://localhost:8181` in your browser instead.

### I made changes to the files and they're not showing up
Run `docker compose up -d --build` again to rebuild the container with your changes.

---

## Your Data is Safe

Any question sets you add through the admin panel are stored in a Docker "volume" — a special persistent storage area. This means your data **survives** even if you stop and restart the container. You only lose data if you explicitly delete the Docker volume with `docker compose down -v` (the `-v` flag deletes volumes, so avoid that unless you want to start fresh).
