From b8e23a56143fe4b00dd72955f53bc3ba62745c25 Mon Sep 17 00:00:00 2001 From: dnviti Date: Sun, 14 Dec 2025 22:55:00 +0100 Subject: [PATCH] build: Add Docker containerization documentation and remove unused variables to resolve TypeScript errors. --- docs/development/CENTRAL.md | 1 + ...25-12-14-235700_docker_containerization.md | 24 +++++++++++++++++++ .../src/modules/draft/DeckBuilderView.tsx | 3 --- src/client/src/modules/draft/DraftView.tsx | 1 - src/client/src/modules/game/GameView.tsx | 2 -- src/server/managers/DraftManager.ts | 2 -- src/server/managers/GameManager.ts | 2 +- 7 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 docs/development/devlog/2025-12-14-235700_docker_containerization.md diff --git a/docs/development/CENTRAL.md b/docs/development/CENTRAL.md index bb11041..c1b2114 100644 --- a/docs/development/CENTRAL.md +++ b/docs/development/CENTRAL.md @@ -17,6 +17,7 @@ The project has successfully migrated from a .NET backend to a Node.js Modular M - **[2025-12-14] Fix Draft Images**: Fixed image loading in Draft UI by adding proxy configuration and correcting property access. [Link](./devlog/2025-12-14-230000_fix_draft_images.md) - **[2025-12-14] Fix Submit Deck**: Implemented `player_ready` handler and state transition to auto-start game when deck is submitted. [Link](./devlog/2025-12-14-233000_fix_submit_deck.md) - **[2025-12-14] Fix Hooks & Waiting State**: Resolved React hook violation crash and added proper waiting screen for ready players. [Link](./devlog/2025-12-14-234500_fix_hooks_and_waiting_state.md) +- **[2025-12-14] Docker Containerization**: Created Dockerfile, fixed build errors, and verified monolithic build. [Link](./devlog/2025-12-14-235700_docker_containerization.md) ## Active Modules 1. **Cube Manager**: Fully functional (Parsing, Fetching, Pack Generation). diff --git a/docs/development/devlog/2025-12-14-235700_docker_containerization.md b/docs/development/devlog/2025-12-14-235700_docker_containerization.md new file mode 100644 index 0000000..3935f58 --- /dev/null +++ b/docs/development/devlog/2025-12-14-235700_docker_containerization.md @@ -0,0 +1,24 @@ +# Docker Containerization and Build Fixes + +## Objectives +- Create a Dockerfile to package the application as a monolith (Node.js + React). +- Fix TypeScript build errors preventing successful compilation. +- Verify the build process. + +## Changes +- **Dockerfile**: Created multi-stage build using `node:20-alpine`. + - Installs dependencies. + - Builds frontend. + - Prunes dev dependencies. +- **Server Entry (`src/server/index.ts`)**: Added logic to serve static `dist` files and handle client-side routing in production. +- **Package.json**: Moved `tsx` to dependencies and updated `start` script. +- **Code Fixes**: Removed unused variables in client and server code used to satisfy strict TypeScript rules: + - `DeckBuilderView.tsx`: Removed unused `payload`. + - `DraftView.tsx`: Removed unused `CardComponent`. + - `GameView.tsx`: Removed unused `myCommand`, `oppGraveyard`. + - `DraftManager.ts`: Removed unused `numPlayers`, `cardIndex`. + - `GameManager.ts`: Renamed unused args in `shuffleLibrary`. + +## Status +- Docker build successful (`docker build -t mtg-draft-maker .`). +- Image ready for deployment. diff --git a/src/client/src/modules/draft/DeckBuilderView.tsx b/src/client/src/modules/draft/DeckBuilderView.tsx index ceddedc..d513262 100644 --- a/src/client/src/modules/draft/DeckBuilderView.tsx +++ b/src/client/src/modules/draft/DeckBuilderView.tsx @@ -79,9 +79,6 @@ export const DeckBuilderView: React.FC = ({ roomId, curren // Host will gather decks? No, that's P2P. // Let's emit 'submit_deck' payload. - const payload = { - [currentPlayerId]: fullDeck - }; // We need a way to accumulate decks on server. // Let's assume we just log it for now and Host starts game with dummy decks or we add logic. // Actually, user rules say "Host ... guided ... configuring packs ... multiplayer". diff --git a/src/client/src/modules/draft/DraftView.tsx b/src/client/src/modules/draft/DraftView.tsx index 518500e..26eb8d8 100644 --- a/src/client/src/modules/draft/DraftView.tsx +++ b/src/client/src/modules/draft/DraftView.tsx @@ -1,7 +1,6 @@ import React, { useState, useEffect } from 'react'; import { socketService } from '../../services/SocketService'; -import { CardComponent } from '../game/CardComponent'; interface DraftViewProps { draftState: any; diff --git a/src/client/src/modules/game/GameView.tsx b/src/client/src/modules/game/GameView.tsx index 1187a85..113ff8a 100644 --- a/src/client/src/modules/game/GameView.tsx +++ b/src/client/src/modules/game/GameView.tsx @@ -55,11 +55,9 @@ export const GameView: React.FC = ({ gameState, currentPlayerId } const myGraveyard = getCards(currentPlayerId, 'graveyard'); const myLibrary = getCards(currentPlayerId, 'library'); const myExile = getCards(currentPlayerId, 'exile'); - const myCommand = getCards(currentPlayerId, 'command'); const oppBattlefield = getCards(opponentId, 'battlefield'); const oppHand = getCards(opponentId, 'hand'); // Should be hidden/count only - const oppGraveyard = getCards(opponentId, 'graveyard'); const oppLibrary = getCards(opponentId, 'library'); return ( diff --git a/src/server/managers/DraftManager.ts b/src/server/managers/DraftManager.ts index 73b1933..ca244a7 100644 --- a/src/server/managers/DraftManager.ts +++ b/src/server/managers/DraftManager.ts @@ -38,7 +38,6 @@ export class DraftManager extends EventEmitter { createDraft(roomId: string, players: string[], allPacks: Pack[]): DraftState { // Distribute 3 packs to each player - const numPlayers = players.length; // Assume allPacks contains (3 * numPlayers) packs // Shuffle packs just in case (optional, but good practice) @@ -83,7 +82,6 @@ export class DraftManager extends EventEmitter { if (!playerState || !playerState.activePack) return null; // Find card - const cardIndex = playerState.activePack.cards.findIndex(c => c.id === cardId || (c as any).uniqueId === cardId); // uniqueId check implies if cards have unique instance IDs in pack, if not we rely on strict equality or assume 1 instance per pack // Fallback: If we can't find by ID (if Scryfall ID generic), just pick the first matching ID? diff --git a/src/server/managers/GameManager.ts b/src/server/managers/GameManager.ts index 9bca0ad..192f57c 100644 --- a/src/server/managers/GameManager.ts +++ b/src/server/managers/GameManager.ts @@ -138,7 +138,7 @@ export class GameManager { } } - private shuffleLibrary(game: GameState, action: { playerId: string }) { + private shuffleLibrary(_game: GameState, _action: { playerId: string }) { // In a real implementation we would shuffle the order array. // Since we retrieve by filtering currently, we don't have order. // We need to implement order index if we want shuffling.