commit c331121d18505bea1717c658000950b3219bf4bd Author: lamtruong28 Date: Wed Nov 11 23:43:28 2026 +0700 Add all files to repository diff --git a/.env.template b/.env.template new file mode 100644 index 0000000..e465f9a --- /dev/null +++ b/.env.template @@ -0,0 +1,34 @@ +# Frontend environments +VITE_PORT = +VITE_API_BASE_URL = +VITE_API_WS_URL = +VITE_SECURITY_CODE = + +# Backend environments +DEBUG = +SECRET_KEY = +ALLOWED_HOSTS = +PER_PAGE_SIZE = +# Database +MYSQL_PORT= +DATABASE_NAME = +DATABASE_USER = +DATABASE_PASSWORD = +DATABASE_HOST = + +DJANGO_SUPERUSER_USERNAME = +DJANGO_SUPERUSER_EMAIL = +DJANGO_SUPERUSER_PASSWORD = + +# Redis +REDIS_PORT = + +# Watchtower +WATCHTOWER_HTTP_API_TOKEN = +UPDATE_HOOK_TOKEN = +WATCHTOWER_URL = + +# Registry Images +FRONTEND_IMAGE = +BACKEND_IMAGE = +RELEASE_API_URL = diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..be687ed --- /dev/null +++ b/Readme.md @@ -0,0 +1,41 @@ +# Setup Project on Mini PC (Windows) + +In the `scripts` folder there are several `.bat` files used to set up the environment on the mini PC. + +## Requirements + +- Create an `Apps` folder on the `C` drive. +- Clone this repository into the `Apps` directory. Note that should not rename the directory you have just cloned. + +## Steps + +1. **Update and rename `.env.template` file to `.env`** + +2. **Run `setup-wsl.bat`** + - This will install WSL with Ubuntu‑22.04. + - Follow the prompts to create a default UNIX user account inside WSL. + +3. **Run `setup-docker.bat`** + - This will install Docker Engine (v2) and Docker Compose V2 inside the Ubuntu WSL you just created. + - It also enables the Docker daemon to start automatically. + +4. **Run `setup-prj.bat`** + - Login docker to Gitea. + - Create `walmart` folder in WSL. + - Copy `.env` and `compose` files to `walmart` folder. + - Run docker compose file `docker compose up -d`. + +5. **Run `update-prj.bat`** + - This will pull latest image from container registry. + - Restart all containers in compose file + - Remove unused images (old images) + +## Notes + +- During these steps, you may be asked to enter your UNIX user password (for `sudo` commands). +- Make sure you reboot your PC after running `setup-wsl.bat` before continuing with the next scripts. +- Verify installation by running: + ```bash + docker --version + docker compose version + ``` diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..4b53192 --- /dev/null +++ b/compose.yml @@ -0,0 +1,160 @@ +services: + + proxy: + image: traefik:v2.11 + container_name: tv-proxy-prod + restart: unless-stopped + + command: + - --providers.docker=true + - --providers.docker.exposedbydefault=false + - --entrypoints.web.address=:3000 + - --api.insecure=true + + ports: + - "3000:3000" + + volumes: + - /var/run/docker.sock:/var/run/docker.sock + + networks: + - tv-network-prod + + redis: + image: redis:8.4.0-alpine + container_name: tv-redis-prod + restart: unless-stopped + + ports: + - "${REDIS_PORT}:6379" + + volumes: + - tv-redis-prod:/data + + networks: + - tv-network-prod + + labels: + - "com.centurylinklabs.watchtower.enable=false" + + mysql: + image: mysql:8.0 + container_name: tv-db-prod + restart: unless-stopped + + ports: + - "${MYSQL_PORT}:3306" + + environment: + MYSQL_DATABASE: ${DATABASE_NAME} + MYSQL_ROOT_PASSWORD: ${DATABASE_PASSWORD} + + volumes: + - tv-data-prod:/var/lib/mysql + + cap_add: + - SYS_NICE + + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] + interval: 10s + timeout: 5s + retries: 10 + + networks: + - tv-network-prod + + labels: + - "com.centurylinklabs.watchtower.enable=false" + + backend: + image: ${BACKEND_IMAGE} + + container_name: tv-backend-prod + restart: unless-stopped + + depends_on: + mysql: + condition: service_healthy + env_file: + - .env + + volumes: + - /var/run/docker.sock:/var/run/docker.sock + + networks: + - tv-network-prod + + labels: + - "traefik.enable=true" + - "traefik.http.routers.backend.rule=PathPrefix(`/api`) || PathPrefix(`/static`) || PathPrefix(`/admin`) || PathPrefix(`/ws`)" + - "traefik.http.routers.backend.entrypoints=web" + - "traefik.http.services.backend.loadbalancer.server.port=8000" + + - "com.centurylinklabs.watchtower.enable=true" + - "com.centurylinklabs.watchtower.lifecycle.post-update=/app/scripts/post-update.sh" + + frontend: + image: ${FRONTEND_IMAGE} + + container_name: tv-frontend-prod + restart: unless-stopped + + depends_on: + - backend + + environment: + - CHOKIDAR_USEPOLLING=False + env_file: + - .env + + networks: + - tv-network-prod + + labels: + - "traefik.enable=true" + - "traefik.http.routers.frontend.rule=PathPrefix(`/`)" + - "traefik.http.routers.frontend.entrypoints=web" + - "traefik.http.services.frontend.loadbalancer.server.port=80" + + - "com.centurylinklabs.watchtower.enable=true" + - "com.centurylinklabs.watchtower.lifecycle.post-update=/app/scripts/post-update.sh" + + watchtower: + image: containrrr/watchtower:1.7.1 + container_name: tv-watchtower-prod + + restart: unless-stopped + + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - /root/.docker/config.json:/config.json:ro + + command: + - --http-api-update + - --cleanup + - --no-startup-message + + environment: + - WATCHTOWER_HTTP_API_TOKEN=${WATCHTOWER_HTTP_API_TOKEN} + - WATCHTOWER_LIFECYCLE_HOOKS=true + + ports: + - "8080:8080" + + networks: + - tv-network-prod + + labels: + - "com.centurylinklabs.watchtower.enable=false" + +volumes: + tv-data-prod: + name: tv-data-prod + + tv-redis-prod: + name: tv-redis-prod + +networks: + tv-network-prod: + driver: bridge \ No newline at end of file diff --git a/scripts/setup-docker.bat b/scripts/setup-docker.bat new file mode 100644 index 0000000..8d26809 --- /dev/null +++ b/scripts/setup-docker.bat @@ -0,0 +1,22 @@ +@echo off +echo Adding official Docker repository... +wsl -d Ubuntu-22.04 bash -c "sudo apt-get update && sudo apt-get install -y ca-certificates curl gnupg lsb-release" +wsl -d Ubuntu-22.04 bash -c "sudo install -m 0755 -d /etc/apt/keyrings" +wsl -d Ubuntu-22.04 bash -c "curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg" +wsl -d Ubuntu-22.04 bash -c "echo 'deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable' | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null" + +echo Installing Docker Engine 28.3.2 + Docker Compose V2... +wsl -d Ubuntu-22.04 bash -c "sudo apt-get update && sudo apt-get install -y docker-ce=5:28.3.2-1~ubuntu.22.04~jammy docker-ce-cli=5:28.3.2-1~ubuntu.22.04~jammy containerd.io docker-compose-plugin" + +echo Holding Docker packages to prevent auto-upgrade... +wsl -d Ubuntu-22.04 bash -c "sudo apt-mark hold docker-ce docker-ce-cli containerd.io" + +echo Enabling Docker daemon... +wsl -d Ubuntu-22.04 bash -c "sudo systemctl enable docker && sudo systemctl start docker" + +echo ============================================ +echo Setup complete! Checking versions... +wsl -d Ubuntu-22.04 bash -c "docker --version" +wsl -d Ubuntu-22.04 bash -c "docker compose version" +echo ============================================ +pause diff --git a/scripts/setup-prj.bat b/scripts/setup-prj.bat new file mode 100644 index 0000000..7edae39 --- /dev/null +++ b/scripts/setup-prj.bat @@ -0,0 +1,27 @@ +@echo off +REM ============================================ +REM Clone source code and start Docker Compose +REM ============================================ + +echo Login docker +wsl -d Ubuntu-22.04 bash -c "sudo docker login gitea.digitoolsolutions.synology.me" + +echo [1/3] Copying files into WSL... +REM Create ~/walmart folder in WSL +wsl -d Ubuntu-22.04 bash -c "mkdir -p ~/walmart" + +REM Copy docker-compose.yml and .env from Windows to WSL +wsl -d Ubuntu-22.04 bash -c "cp /mnt/c/Apps/mini-pc-setup/compose.yml ~/walmart/" +wsl -d Ubuntu-22.04 bash -c "cp /mnt/c/Apps/mini-pc-setup/.env ~/walmart/" + +echo [2/3] Starting containers... +wsl -d Ubuntu-22.04 bash -c "cd ~/walmart && sudo docker compose up -d" + +echo [3/3] Showing running containers... +wsl -d Ubuntu-22.04 bash -c "sudo docker ps" + +echo ============================================ +echo Project 'walmart' is up and running! +echo ============================================ + +pause diff --git a/scripts/setup-wsl.bat b/scripts/setup-wsl.bat new file mode 100644 index 0000000..f7cb784 --- /dev/null +++ b/scripts/setup-wsl.bat @@ -0,0 +1,5 @@ +@echo off +echo Installing WSL with Ubuntu-22.04... +wsl --install -d Ubuntu-22.04 +echo Please reboot your computer and create your Ubuntu user before continuing. +pause diff --git a/scripts/update-prj.bat b/scripts/update-prj.bat new file mode 100644 index 0000000..542150e --- /dev/null +++ b/scripts/update-prj.bat @@ -0,0 +1,26 @@ +@echo off + +echo ============================================ +echo Updating Walmart containers... +echo ============================================ + +echo [1/4] Update config... +wsl -d Ubuntu-22.04 bash -c "cp /mnt/c/Apps/mini-pc-setup/compose.yml ~/walmart/" +wsl -d Ubuntu-22.04 bash -c "cp /mnt/c/Apps/mini-pc-setup/.env ~/walmart/" + +echo [2/4] Pull latest images... +wsl -d Ubuntu-22.04 bash -c "cd ~/walmart && sudo docker compose pull" + +echo [3/4] Restart containers... +wsl -d Ubuntu-22.04 bash -c "cd ~/walmart && sudo docker compose up -d" + +echo [4/4] Remove unused images... +wsl -d Ubuntu-22.04 bash -c "sudo docker image prune -af" + +pause +echo. +echo ============================================ +echo Walmart update completed! +echo ============================================ + +pause \ No newline at end of file diff --git a/templates/startup-screen.html b/templates/startup-screen.html new file mode 100644 index 0000000..fb0c91a --- /dev/null +++ b/templates/startup-screen.html @@ -0,0 +1,119 @@ + + + + + Kiosk Startup + + + +
+

Welcome to DTS Torque Vault

+
+
+
+
+

Loading system resources, please wait

+
+ + + +