9 Commits

Author SHA1 Message Date
4a3daf7d8c SSL configuration in Dockerfile and drone.yml
Some checks reported errors
continuous-integration/drone/tag Build was killed
2025-11-29 19:22:06 +05:30
13ad4e08d2 SSL configuration
All checks were successful
continuous-integration/drone/tag Build is passing
2025-11-29 19:16:15 +05:30
7e35cf0c31 fixes
All checks were successful
continuous-integration/drone/tag Build is passing
2025-11-29 19:04:17 +05:30
18d43f9481 fixes
All checks were successful
continuous-integration/drone/tag Build is passing
2025-11-29 18:50:57 +05:30
5662d22481 deployment files 2025-11-29 18:49:40 +05:30
a996fe7b3c bug fix where new username cannot be fully entered 2025-11-29 18:44:33 +05:30
ecb8825734 client config via .env file 2025-11-29 16:46:56 +05:30
d4edf049ed title fix 2025-11-29 04:21:34 +05:30
d1f4ec0266 bumped up version 2025-11-29 04:01:38 +05:30
8 changed files with 241 additions and 5 deletions

40
.dockerignore Normal file
View File

@@ -0,0 +1,40 @@
# Node modules
node_modules
**/node_modules
# Logs
*.log
logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Build outputs
build
dist
out
.next
.cache
.parcel-cache
# Environment files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
# OS files
.DS_Store
Thumbs.db
# IDE / Editor folders
.vscode
.idea
*.sublime-workspace
*.sublime-project
# Temporary files
*.swp
*.bak
*.tmp

146
.drone.yml Normal file
View File

@@ -0,0 +1,146 @@
---
kind: pipeline
type: docker
name: default
platform:
os: linux
arch: arm64
workspace:
path: /drone/src
volumes:
- name: dockersock
host:
path: /var/run/docker.sock
steps:
- name: fetch-tags
image: docker:24
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- apk add --no-cache git
- git fetch --tags
- |
# Get latest Git tag and trim newline
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null | tr -d '\n')
echo "Latest Git tag fetched: $LATEST_TAG"
# Save to file for downstream steps
echo "$LATEST_TAG" > /drone/src/LATEST_TAG.txt
# Read back for verification
IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
echo "Image tag read from file: $IMAGE_TAG"
# Validate
if [ -z "$IMAGE_TAG" ]; then
echo "❌ No git tags found! Cannot continue."
exit 1
fi
- name: check-remote-image
image: docker:24
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
- echo "Checking if lila-games/tic-tac-toe-ui:$IMAGE_TAG exists on remote Docker..."
- echo "Existing Docker tags for lila-games/tic-tac-toe-ui:"
- docker images --format "{{.Repository}}:{{.Tag}}" | grep "^lila-games/tic-tac-toe-ui" || echo "(none)"
- |
if docker image inspect lila-games/tic-tac-toe-ui:$IMAGE_TAG > /dev/null 2>&1; then
echo "✅ Docker image lila-games/tic-tac-toe-ui:$IMAGE_TAG already exists — skipping build"
exit 78
else
echo "⚙️ Docker image lila-games/tic-tac-toe-ui:$IMAGE_TAG not found — proceeding to build..."
fi
- name: build-image
image: docker:24
environment:
WS_HOST:
from_secret: WS_HOST
WS_PORT:
from_secret: WS_PORT
WS_SKEY:
from_secret: WS_SKEY
WS_SSL:
from_secret: WS_SSL
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
- echo "🔨 Building Docker image lila-games/tic-tac-toe-ui:$IMAGE_TAG ..."
- |
docker build --network=host \
--build-arg VITE_WS_HOST="$WS_HOST" \
--build-arg VITE_WS_PORT="$WS_PORT" \
--build-arg VITE_WS_SKEY="$WS_SKEY" \
--build-arg VITE_WS_SSL="$WS_SSL" \
-t lila-games/tic-tac-toe-ui:$IMAGE_TAG \
-t lila-games/tic-tac-toe-ui:latest \
/drone/src
- name: push-image
image: docker:24
environment:
REGISTRY_HOST:
from_secret: REGISTRY_HOST
REGISTRY_USER:
from_secret: REGISTRY_USER
REGISTRY_PASS:
from_secret: REGISTRY_PASS
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
- echo "🔑 Logging into registry $REGISTRY_HOST ..."
- echo "$REGISTRY_PASS" | docker login $REGISTRY_HOST -u "$REGISTRY_USER" --password-stdin
- echo "🏷️ Tagging images with registry prefix..."
- docker tag lila-games/tic-tac-toe-ui:$IMAGE_TAG $REGISTRY_HOST/lila-games/tic-tac-toe-ui:$IMAGE_TAG
- docker tag lila-games/tic-tac-toe-ui:$IMAGE_TAG $REGISTRY_HOST/lila-games/tic-tac-toe-ui:latest
- echo "📤 Pushing lila-games/tic-tac-toe-ui:$IMAGE_TAG ..."
- docker push $REGISTRY_HOST/lila-games/tic-tac-toe-ui:$IMAGE_TAG
- echo "📤 Pushing lila-games/tic-tac-toe-ui:latest ..."
- docker push $REGISTRY_HOST/lila-games/tic-tac-toe-ui:latest
- name: stop-old
image: docker:24
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- echo "🛑 Stopping old container..."
- docker rm -f tic-tac-toe-ui || true
- name: run-container
image: docker:24
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
- echo "🚀 Starting container lila-games/tic-tac-toe-ui:$IMAGE_TAG ..."
- |
docker run -d \
--name tic-tac-toe-ui \
-p 3003:3000 \
-e NODE_ENV=production \
--restart always \
lila-games/tic-tac-toe-ui:$IMAGE_TAG
# Trigger rules
trigger:
event:
- tag

42
Dockerfile Normal file
View File

@@ -0,0 +1,42 @@
# Stage 1: Build
FROM node:20-alpine AS builder
# Set working directory
WORKDIR /app
# Copy package.json and package-lock.json (or yarn.lock)
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy the rest of the app
COPY . .
# Build arguments
ARG VITE_WS_HOST
ARG VITE_WS_PORT
ARG VITE_WS_SKEY
ARG VITE_WS_SSL
# Export them as actual environment variables (Vite needs ENV)
ENV VITE_WS_HOST=${VITE_WS_HOST}
ENV VITE_WS_PORT=${VITE_WS_PORT}
ENV VITE_WS_SSL=${VITE_WS_SSL}
# Build
RUN npm run build
# Stage 2: Static file server (BusyBox)
FROM busybox:latest
WORKDIR /app
# Copy only build frontend files
COPY --from=builder /app/dist /app
# Expose port
EXPOSE 3000
# Default command
CMD ["busybox", "httpd", "-f", "-p", "3000"]

View File

@@ -9,7 +9,7 @@
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap"
/>
<title>Blog - Aetoskia</title>
<title>TicTacToe - Aetoskia</title>
</head>
<body>
<div id="root"></div>

View File

@@ -1,6 +1,6 @@
{
"name": "tictactoe-vite",
"version": "v0.2.0",
"version": "v0.2.5",
"private": true,
"scripts": {
"dev": "vite",

View File

@@ -22,6 +22,7 @@ export default function Player({
);
const [selectedMode, setSelectedMode] = useState("classic");
const [isQueueing, setIsQueueing] = useState(false);
const isRegistered = localStorage.getItem("registered") === "yes";
// ------------------------------------------
// CONNECT
@@ -86,7 +87,7 @@ export default function Player({
<input
placeholder="Enter username"
value={username}
disabled={username.length > 0}
disabled={isRegistered}
onChange={(e) => setUsername(e.target.value)}
style={{
padding: "10px",

View File

@@ -47,7 +47,12 @@ export const NakamaContext = createContext<NakamaContextType>(null!);
export function NakamaProvider({ children }: { children: React.ReactNode }) {
const [client] = useState(
() => new Client("defaultkey", "127.0.0.1", "7350")
() => new Client(
import.meta.env.VITE_SERVER_KEY,
import.meta.env.VITE_WS_HOST,
import.meta.env.VITE_WS_PORT,
import.meta.env.VITE_WS_SSL === "true"
)
);
const [session, setSession] = useState<Session | null>(null);

4
src/vite-env.d.ts vendored
View File

@@ -1,7 +1,9 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_WS_BASE_URL: string;
readonly VITE_WS_HOST: string;
readonly VITE_WS_PORT: string;
readonly VITE_WS_SKEY: string;
}
interface ImportMeta {