Skip to content

Commit 91cc356

Browse files
authored
Merge pull request #25 from Ralex91/v1.0.0
V1.0.0
2 parents 8f73241 + b915316 commit 91cc356

149 files changed

Lines changed: 9190 additions & 8850 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.pnpm-store
3+
.git

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
WEB_ORIGIN=http://localhost:3000 # Default: http://localhost:3000, for allow all origins use '*'
2+
SOCKET_URL=http://localhost:3001 # Default: http://localhost:3001

.github/logo.svg

Lines changed: 4 additions & 1 deletion
Loading

.github/preview1.jpg

65.7 KB
Loading

.github/preview2.jpg

551 KB
Loading

.github/preview3.jpg

446 KB
Loading
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Docker Release
2+
on:
3+
release:
4+
types: [published]
5+
6+
env:
7+
DOCKER_PLATFORMS: |
8+
linux/amd64
9+
linux/arm64
10+
11+
jobs:
12+
build-and-push:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Extract version and tags
22+
run: |
23+
if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
24+
VERSION=${GITHUB_REF_NAME#v}
25+
echo "VERSION=$VERSION" >> $GITHUB_ENV
26+
27+
# Extract major.minor (ex: 1.2.3 -> 1.2)
28+
MAJOR_MINOR=$(echo $VERSION | cut -d. -f1,2)
29+
echo "MAJOR_MINOR=$MAJOR_MINOR" >> $GITHUB_ENV
30+
else
31+
echo "VERSION=latest" >> $GITHUB_ENV
32+
echo "MAJOR_MINOR=latest" >> $GITHUB_ENV
33+
fi
34+
35+
- name: Extract repository name (lowercase)
36+
run: echo "REPO_NAME=$(basename ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
37+
38+
- name: Set up QEMU
39+
uses: docker/setup-qemu-action@v3
40+
with:
41+
platforms: ${{ env.DOCKER_PLATFORMS }}
42+
43+
- name: Set up Docker Buildx
44+
uses: docker/setup-buildx-action@v3
45+
with:
46+
version: latest
47+
install: true
48+
platforms: ${{ env.DOCKER_PLATFORMS }}
49+
50+
- name: Log in to Docker Hub
51+
uses: docker/login-action@v3
52+
with:
53+
username: ${{ secrets.DOCKERHUB_USERNAME }}
54+
password: ${{ secrets.DOCKERHUB_TOKEN }}
55+
56+
- name: Build and push
57+
uses: docker/build-push-action@v6
58+
with:
59+
context: .
60+
platforms: ${{ env.DOCKER_PLATFORMS }}
61+
push: true
62+
tags: |
63+
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPO_NAME }}:${{ env.VERSION }}
64+
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPO_NAME }}:${{ env.MAJOR_MINOR }}
65+
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPO_NAME }}:latest
66+
cache-from: type=gha
67+
cache-to: type=gha,mode=max
68+
build-args: |
69+
BUILDKIT_INLINE_CACHE=1

.gitignore

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,4 @@
1-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2-
3-
# dependencies
41
/node_modules
5-
/socket/node_modules
6-
/.pnp
7-
.pnp.js
8-
.yarn/install-state.gz
9-
10-
# testing
11-
/coverage
12-
13-
# next.js
14-
/.next/
15-
/out/
16-
17-
# production
18-
/build
19-
20-
# misc
21-
.DS_Store
22-
*.pem
23-
24-
# debug
25-
npm-debug.log*
26-
yarn-debug.log*
27-
yarn-error.log*
28-
29-
# local env files
30-
.env*.local
31-
32-
# vercel
33-
.vercel
34-
35-
# typescript
36-
*.tsbuildinfo
37-
next-env.d.ts
2+
.env
3+
.secrets
4+
release.json

.vscode/extensions.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"recommendations": [
33
"esbenp.prettier-vscode",
44
"dbaeumer.vscode-eslint",
5+
"usernamehw.errorlens",
6+
"YoavBls.pretty-ts-errors",
57
"bradlc.vscode-tailwindcss",
68
"meganrogge.template-string-converter",
79
"vincaslt.highlight-matching-tag",

Dockerfile

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
FROM node:22-alpine AS base
2+
3+
# Enable and prepare pnpm via Corepack
4+
RUN corepack enable && corepack prepare pnpm@latest --activate
5+
6+
# ----- DEPENDENCIES -----
7+
FROM base AS deps
8+
WORKDIR /app
9+
10+
# Copy pnpm configuration files
11+
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./
12+
COPY packages/web/package.json ./packages/web/
13+
COPY packages/socket/package.json ./packages/socket/
14+
15+
# Install only production dependencies
16+
RUN pnpm install --frozen-lockfile --prod
17+
18+
# ----- BUILDER -----
19+
FROM base AS builder
20+
WORKDIR /app
21+
22+
# Copy all monorepo files
23+
COPY . .
24+
25+
# Install all dependencies (including dev) for build
26+
RUN pnpm install --frozen-lockfile
27+
28+
# Build Next.js app with standalone output for smaller runtime image
29+
WORKDIR /app/packages/web
30+
31+
ENV NEXT_TELEMETRY_DISABLED=1
32+
33+
RUN pnpm build
34+
35+
# Build socket server if needed (TypeScript or similar)
36+
WORKDIR /app/packages/socket
37+
RUN if [ -f "tsconfig.json" ]; then pnpm build; fi
38+
39+
# ----- RUNNER -----
40+
FROM node:22-alpine AS runner
41+
WORKDIR /app
42+
43+
# Create a non-root user for better security
44+
RUN addgroup --system --gid 1001 nodejs
45+
RUN adduser --system --uid 1001 nodejs
46+
47+
48+
# Enable pnpm in the runtime image
49+
RUN corepack enable && corepack prepare pnpm@latest --activate
50+
51+
# Copy configuration files
52+
COPY pnpm-workspace.yaml package.json ./
53+
54+
# Copy the Next.js standalone build
55+
COPY --from=builder /app/packages/web/.next/standalone ./
56+
COPY --from=builder /app/packages/web/.next/static ./packages/web/.next/static
57+
COPY --from=builder /app/packages/web/public ./packages/web/public
58+
59+
# Copy the socket server build
60+
COPY --from=builder /app/packages/socket/dist ./packages/socket/dist
61+
62+
# Copy the game default config
63+
COPY --from=builder /app/config ./config
64+
65+
# Expose the web and socket ports
66+
EXPOSE 3000 5505
67+
68+
# Environment variables
69+
ENV NODE_ENV=production
70+
ENV CONFIG_PATH=/app/config
71+
72+
# Start both services (Next.js web app + Socket server)
73+
CMD ["sh", "-c", "node packages/web/server.js & node packages/socket/dist/index.cjs"]

0 commit comments

Comments
 (0)