commit cd46057cd2fee2f8d80a7cee586ef41d7804fc20 Author: ejones Date: Mon Mar 30 15:42:39 2026 -0400 inital Jack diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..751a935 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git/ +*.sh +*.bat +README.md +compose.yaml +Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..757fcbc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +# Use a lightweight Nginx image +FROM nginx:alpine + +# Copy the static files to the Nginx html directory +COPY . /usr/share/nginx/html/ + +# Expose port 80 +EXPOSE 80 + +# Start Nginx +CMD ["nginx", "-g", "daemon off;"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..3934710 --- /dev/null +++ b/README.md @@ -0,0 +1,59 @@ +# Calculator + +A simple, scientific calculator that runs in your browser. + +## Dependencies + +This project can be run in a few different ways, and dependencies vary based on the method you choose. + +- **Browser Only**: No dependencies, but the calculator will not be served from a webserver. +- **Python**: To serve the `index.html` file, you'll need Python installed. +- **Docker**: To run the project in a container, you'll need Docker installed. + +## How to Run + +### Windows + +- **With Python**: Run `start-server.bat`. This will start a Python web server and open the calculator in your default browser. +- **With Docker**: Run `run-docker.bat`. This will use Docker Compose to build and run the container. + +### Linux / macOS + +- **With Python**: Run `./start-server.sh`. You may need to make it executable first with `chmod +x start-server.sh`. This will start a Python web server and open the calculator in your default browser. +- **With Docker**: Run `./run-docker.sh`. You may need to make it executable first with `chmod +x run-docker.sh`. This will use Docker Compose to build and run the container. + +## Server Setup + +To deploy the calculator on a server, you only need Docker and Docker Compose installed. You do not need to clone this repository. + +1. **Install Docker and Docker Compose**: Follow the official installation instructions for your server's operating system. + +2. **Create a `compose.yaml` file**: On your server, create a new file named `compose.yaml` and add the following content: + + ```yaml + services: + web: + build: . + image: ghcr.io/jones013/jack_calculator:latest + ports: + - "8888:80" + restart: unless-stopped + ``` + +3. **Start the container**: In the same directory where you created the `compose.yaml` file, run the following command: + + ```bash + docker compose up -d + ``` + +The `-d` flag runs the container in detached mode. The `restart: unless-stopped` policy ensures that the container will automatically restart if the server is rebooted. + +The calculator will then be available at `http://:8888`. + +**Note on Firewalls**: Ensure that your server's firewall is configured to allow incoming traffic on port 8888. + +--- + +## Branches + +Use `**main`** or `**user**` for this layout. Maintainer tooling and full docs live on the `**developer**` branch. diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..1a60d82 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,7 @@ +services: + web: + build: . + image: calculator:latest + ports: + - "8888:80" + restart: unless-stopped diff --git a/gigachad.png b/gigachad.png new file mode 100644 index 0000000..5b8c716 Binary files /dev/null and b/gigachad.png differ diff --git a/images/gigachad.png b/images/gigachad.png new file mode 100644 index 0000000..21fc490 Binary files /dev/null and b/images/gigachad.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..a8fa72f --- /dev/null +++ b/index.html @@ -0,0 +1,671 @@ + + + + + + Scientific Calculator + + + + + +
+
+ GigaChad meme portrait +
+
+

Scientific calculator

+
+ +
+
+
+
0
+
+
+ + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+
+ + + diff --git a/run-docker.bat b/run-docker.bat new file mode 100644 index 0000000..02c20c7 --- /dev/null +++ b/run-docker.bat @@ -0,0 +1,14 @@ +@echo off +setlocal +cd /d "%~dp0" + +where docker >nul 2>&1 +if errorlevel 1 ( + echo Docker not found. Install Docker Desktop. + pause + exit /b 1 +) + +echo Calculator: http://localhost:8888 +start "" "http://localhost:8888" +docker compose up diff --git a/run-docker.sh b/run-docker.sh new file mode 100644 index 0000000..7f12584 --- /dev/null +++ b/run-docker.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail +cd "$(dirname "$0")" + +if ! command -v docker >/dev/null 2>&1; then + echo "Docker not found." + exit 1 +fi + +echo "Calculator: http://localhost:8888" +( + sleep 2 + command -v xdg-open >/dev/null 2>&1 && xdg-open "http://localhost:8888" 2>/dev/null || true + command -v open >/dev/null 2>&1 && open "http://localhost:8888" 2>/dev/null || true +) & + +if docker compose version >/dev/null 2>&1; then + exec docker compose up +fi +if command -v docker-compose >/dev/null 2>&1; then + exec docker-compose up +fi + +echo "Docker Compose not found." +exit 1 diff --git a/start-server.bat b/start-server.bat new file mode 100644 index 0000000..62d478a --- /dev/null +++ b/start-server.bat @@ -0,0 +1,23 @@ +@echo off +setlocal +cd /d "%~dp0" + +where python >nul 2>&1 +if %errorlevel% equ 0 ( + set "PY=python" +) else ( + where py >nul 2>&1 + if errorlevel 1 ( + echo Python not found. Install from https://www.python.org/ + pause + exit /b 1 + ) + set "PY=py" +) + +echo Calculator: http://localhost:8888 +start "" "http://localhost:8888" +"%PY%" -m http.server 8888 --bind 127.0.0.1 + +echo. +pause diff --git a/start-server.sh b/start-server.sh new file mode 100644 index 0000000..ba7df30 --- /dev/null +++ b/start-server.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -euo pipefail +cd "$(dirname "$0")" + +if command -v python3 >/dev/null 2>&1; then + PY=python3 +elif command -v python >/dev/null 2>&1; then + PY=python +else + echo "Python not found." + exit 1 +fi + +echo "Calculator: http://localhost:8888" +( + sleep 1 + command -v xdg-open >/dev/null 2>&1 && xdg-open "http://localhost:8888" 2>/dev/null || true + command -v open >/dev/null 2>&1 && open "http://localhost:8888" 2>/dev/null || true +) & + +exec "$PY" -m http.server 8888 --bind 127.0.0.1