From bc92824b4c4b115e700fd805656b87f04ffedec4 Mon Sep 17 00:00:00 2001 From: Domagoj Date: Sat, 26 Jul 2025 10:23:11 +0200 Subject: [PATCH 1/9] Add Dockerfile --- Dockerfile | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000000..74d8e8ca9a1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# syntax=docker/dockerfile:1 +ARG NODE_VERSION=${NODE_VERSION:-22.14} +ARG OS=${OS:-alpine} + +FROM node:${NODE_VERSION}-${OS} + +ENV VITE_BYPASS_LOGIN=1 \ + VITE_BYPASS_TUTORIAL=0 \ + NEXT_TELEMETRY_DISABLED=1 \ + PNP_HOME=/root/.shrc \ + NODE_ENV=production \ + PORT=8000 + +RUN apk add --no-cache git + +WORKDIR /app + +RUN corepack enable && corepack prepare pnpm@10 --activate + +COPY . . + +RUN --mount=type=bind,source=package.json,target=package.json \ + --mount=type=bind,source=package-lock.json,target=package-lock.json \ + --mount=type=cache,target=/root/.npm \ + npm ci + +RUN pnpm install + +EXPOSE $PORT + +CMD pnpm start:dev -- --host --port $PORT \ No newline at end of file From c088b08e773918daa75afd3ff542a5156ad82ed9 Mon Sep 17 00:00:00 2001 From: Domagoj Date: Tue, 29 Jul 2025 15:04:40 +0200 Subject: [PATCH 2/9] Refactor for improved podman support --- Dockerfile | 44 +++++++++++++++++++++++++++++++++----------- package.json | 1 + 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 74d8e8ca9a1..bfba5cabcdf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,31 +1,53 @@ # syntax=docker/dockerfile:1 -ARG NODE_VERSION=${NODE_VERSION:-22.14} -ARG OS=${OS:-alpine} +ARG NODE_VERSION=22.14 +ARG OS=alpine FROM node:${NODE_VERSION}-${OS} +# Create non-root user for rootless operation +RUN addgroup -S appgroup && adduser -S appuser -G appgroup + +# Install git (already present, but ensure it’s available) +RUN apk add --no-cache git + +# Set environment variables ENV VITE_BYPASS_LOGIN=1 \ VITE_BYPASS_TUTORIAL=0 \ NEXT_TELEMETRY_DISABLED=1 \ - PNP_HOME=/root/.shrc \ + PNP_HOME=/home/appuser/.shrc \ NODE_ENV=production \ PORT=8000 -RUN apk add --no-cache git - +# Set working directory WORKDIR /app +# Enable and prepare pnpm RUN corepack enable && corepack prepare pnpm@10 --activate +# Copy package files first for caching +COPY package.json pnpm-lock.yaml ./ + +# Initialize Git repository and copy .git (for submodules and lefthook) +COPY .git ./.git +COPY .gitmodules ./.gitmodules + +# Install dependencies and initialize submodules +RUN --mount=type=cache,target=/home/appuser/.pnpm-store \ + git config --global --add safe.directory /app && \ + git submodule update --init --recursive && \ + pnpm install --frozen-lockfile + +# Copy remaining files COPY . . -RUN --mount=type=bind,source=package.json,target=package.json \ - --mount=type=bind,source=package-lock.json,target=package-lock.json \ - --mount=type=cache,target=/root/.npm \ - npm ci +# Change ownership for rootless compatibility +RUN chown -R appuser:appgroup /app -RUN pnpm install +# Switch to non-root user +USER appuser +# Expose port EXPOSE $PORT -CMD pnpm start:dev -- --host --port $PORT \ No newline at end of file +# Start the app +CMD ["pnpm", "start:podman", "--", "--host", "--port", "$PORT"] \ No newline at end of file diff --git a/package.json b/package.json index 64f2f9786db..41dc6b04f90 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "start": "vite", "start:dev": "vite --mode development", + "start:podman": "vite --mode development --host 0.0.0.0 --port $PORT", "build": "vite build", "build:beta": "vite build --mode beta", "preview": "vite preview", From 12f408dc0a7302d962868decf9b44dc7f8ab4a00 Mon Sep 17 00:00:00 2001 From: Domagoj Date: Tue, 29 Jul 2025 17:39:12 +0200 Subject: [PATCH 3/9] Podman support + docs --- .dockerignore | 7 +++++++ Dockerfile | 48 +++++++++++++++++++++--------------------------- docs/podman.md | 6 ++++++ 3 files changed, 34 insertions(+), 27 deletions(-) create mode 100644 .dockerignore create mode 100644 docs/podman.md diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000000..219c096336b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +# .dockerignore +node_modules +*.log +*.md +.gitignore +Dockerfile +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index bfba5cabcdf..7e8af3699bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,50 +4,44 @@ ARG OS=alpine FROM node:${NODE_VERSION}-${OS} -# Create non-root user for rootless operation +# Create non-root user RUN addgroup -S appgroup && adduser -S appuser -G appgroup -# Install git (already present, but ensure it’s available) +# Install git (for potential runtime needs) RUN apk add --no-cache git -# Set environment variables -ENV VITE_BYPASS_LOGIN=1 \ - VITE_BYPASS_TUTORIAL=0 \ - NEXT_TELEMETRY_DISABLED=1 \ - PNP_HOME=/home/appuser/.shrc \ - NODE_ENV=production \ - PORT=8000 - # Set working directory WORKDIR /app # Enable and prepare pnpm RUN corepack enable && corepack prepare pnpm@10 --activate -# Copy package files first for caching -COPY package.json pnpm-lock.yaml ./ - -# Initialize Git repository and copy .git (for submodules and lefthook) -COPY .git ./.git -COPY .gitmodules ./.gitmodules - -# Install dependencies and initialize submodules -RUN --mount=type=cache,target=/home/appuser/.pnpm-store \ - git config --global --add safe.directory /app && \ - git submodule update --init --recursive && \ - pnpm install --frozen-lockfile - -# Copy remaining files COPY . . -# Change ownership for rootless compatibility +# Copy package files +COPY package.json pnpm-lock.yaml ./ + +# Install all dependencies, skipping postinstall +RUN --mount=type=cache,target=/home/appuser/.pnpm-store \ + pnpm install --frozen-lockfile && \ + rm -rf /home/appuser/.pnpm-store/* + +# Change ownership RUN chown -R appuser:appgroup /app # Switch to non-root user USER appuser +# Set environment variables +ENV VITE_BYPASS_LOGIN=1 \ + VITE_BYPASS_TUTORIAL=0 \ + NEXT_TELEMETRY_DISABLED=1 \ + PNP_HOME=/home/appuser/.shrc \ + NODE_ENV=development \ + PORT=8000 + # Expose port EXPOSE $PORT -# Start the app -CMD ["pnpm", "start:podman", "--", "--host", "--port", "$PORT"] \ No newline at end of file +# Start the app in development mode +CMD ["pnpm", "run", "start:podman"] \ No newline at end of file diff --git a/docs/podman.md b/docs/podman.md new file mode 100644 index 00000000000..9cd6a2777a3 --- /dev/null +++ b/docs/podman.md @@ -0,0 +1,6 @@ +# Using with Podman + +1. `podman build -t pokerogue:1.0 -f Dockerfile .` +2. `podman run --rm -p 8000:8000 localhost/pokerogue:1.0` +3. Visit `http://localhost:8000/` + From 98ab49c1b2e3de2eae1a35f3dd91d92bdc66fd2f Mon Sep 17 00:00:00 2001 From: Domagoj Date: Tue, 29 Jul 2025 19:02:08 +0200 Subject: [PATCH 4/9] Update documentation for podman usage --- docs/podman.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/podman.md b/docs/podman.md index 9cd6a2777a3..87c3d7d973c 100644 --- a/docs/podman.md +++ b/docs/podman.md @@ -1,6 +1,11 @@ -# Using with Podman +# Using Podman -1. `podman build -t pokerogue:1.0 -f Dockerfile .` -2. `podman run --rm -p 8000:8000 localhost/pokerogue:1.0` +## Requirements + +* `podman >=5.x` + +## Steps + +1. `podman build -t pokerogue -f Dockerfile .` +2. `podman run --rm -p 8000:8000 localhost/pokerogue` 3. Visit `http://localhost:8000/` - From 28c535cadc58cca067b30d9c953c7c5a20443259 Mon Sep 17 00:00:00 2001 From: Domagoj Date: Fri, 15 Aug 2025 11:33:38 +0200 Subject: [PATCH 5/9] Update docs/podman.md with working podman run command --- docs/podman.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/podman.md b/docs/podman.md index 87c3d7d973c..4105c969be1 100644 --- a/docs/podman.md +++ b/docs/podman.md @@ -7,5 +7,7 @@ ## Steps 1. `podman build -t pokerogue -f Dockerfile .` -2. `podman run --rm -p 8000:8000 localhost/pokerogue` +2. `podman run --rm -p 8000:8000 -v $(pwd):/app:Z --userns=keep-id -u $(id -u):$(id -g) localhost/pokerogue` 3. Visit `http://localhost:8000/` + +Note: `podman run` may take a couple of minutes to mount the working directory \ No newline at end of file From 72b86ca6ad499a9b43b08167dbf8f00d7b2edc0a Mon Sep 17 00:00:00 2001 From: Domagoj Date: Fri, 15 Aug 2025 13:50:35 +0200 Subject: [PATCH 6/9] Add package manager constraint to package.json and Dockerfile Update podman.md docs --- Dockerfile | 2 +- docs/podman.md | 14 +++++++++++--- package.json | 3 ++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7e8af3699bc..4b186b258f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ RUN apk add --no-cache git WORKDIR /app # Enable and prepare pnpm -RUN corepack enable && corepack prepare pnpm@10 --activate +RUN corepack enable && corepack prepare pnpm@10.14.0 --activate COPY . . diff --git a/docs/podman.md b/docs/podman.md index 4105c969be1..7f1c2d8a653 100644 --- a/docs/podman.md +++ b/docs/podman.md @@ -7,7 +7,15 @@ ## Steps 1. `podman build -t pokerogue -f Dockerfile .` -2. `podman run --rm -p 8000:8000 -v $(pwd):/app:Z --userns=keep-id -u $(id -u):$(id -g) localhost/pokerogue` -3. Visit `http://localhost:8000/` +2. `podman create --name temp-pokerogue localhost/pokerogue` +3. `podman cp temp-pokerogue:/app/node_modules ./` +4. `podman rm temp-pokerogue` +5. `podman run --rm -p 8000:8000 -v $(pwd):/app:Z --userns=keep-id -u $(id -u):$(id -g) localhost/pokerogue` +6. Visit `http://localhost:8000/` -Note: `podman run` may take a couple of minutes to mount the working directory \ No newline at end of file +Note: + +1. Steps 2,3,4 are required because mounting working directory without installed `node_modules/` locally will be empty, +this way we prevent it by copying them from the container itself to local directory + +2. `podman run` may take a couple of minutes to mount the working directory \ No newline at end of file diff --git a/package.json b/package.json index 29439f7186b..9c0ee8a43cc 100644 --- a/package.json +++ b/package.json @@ -63,5 +63,6 @@ }, "engines": { "node": ">=22.0.0" - } + }, + "packageManager": "pnpm@10.14.0" } From 7b1b91647c6eacc67f4fa9e6d2a719c6526ee23b Mon Sep 17 00:00:00 2001 From: Domagoj Date: Sat, 16 Aug 2025 14:59:27 +0200 Subject: [PATCH 7/9] Remove package manager constraints from github workflows per DayKev Update podman.md docs with extra steps for locales and testing command Remove missleading comment from Dockerfile --- .github/workflows/deploy-beta.yml | 2 -- .github/workflows/deploy.yml | 2 -- .github/workflows/github-pages.yml | 2 -- .github/workflows/linting.yml | 2 -- .github/workflows/test-shard-template.yml | 2 -- docs/podman.md | 14 ++++++++++---- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deploy-beta.yml b/.github/workflows/deploy-beta.yml index 0894032c8ad..b12e0f1f83a 100644 --- a/.github/workflows/deploy-beta.yml +++ b/.github/workflows/deploy-beta.yml @@ -21,8 +21,6 @@ jobs: - name: Install pnpm uses: pnpm/action-setup@v4 - with: - version: 10 - uses: actions/setup-node@v4 with: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0e7102a41dd..439f1e7749f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -19,8 +19,6 @@ jobs: - name: Install pnpm uses: pnpm/action-setup@v4 - with: - version: 10 - uses: actions/setup-node@v4 with: diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 1588a15afeb..994409bbb30 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -37,8 +37,6 @@ jobs: - name: Install pnpm uses: pnpm/action-setup@v4 - with: - version: 10 - name: Setup Node 22.14.1 uses: actions/setup-node@v4 diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 82f5abd23a1..b6edb11ebe6 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -25,8 +25,6 @@ jobs: - name: Install pnpm uses: pnpm/action-setup@v4 - with: - version: 10 - name: Set up Node.js uses: actions/setup-node@v4 diff --git a/.github/workflows/test-shard-template.yml b/.github/workflows/test-shard-template.yml index 124004f380f..80fca34bcb2 100644 --- a/.github/workflows/test-shard-template.yml +++ b/.github/workflows/test-shard-template.yml @@ -31,8 +31,6 @@ jobs: - name: Install pnpm uses: pnpm/action-setup@v4 - with: - version: 10 - name: Set up Node.js uses: actions/setup-node@v4 diff --git a/docs/podman.md b/docs/podman.md index 7f1c2d8a653..80fee3258d1 100644 --- a/docs/podman.md +++ b/docs/podman.md @@ -9,13 +9,19 @@ 1. `podman build -t pokerogue -f Dockerfile .` 2. `podman create --name temp-pokerogue localhost/pokerogue` 3. `podman cp temp-pokerogue:/app/node_modules ./` -4. `podman rm temp-pokerogue` -5. `podman run --rm -p 8000:8000 -v $(pwd):/app:Z --userns=keep-id -u $(id -u):$(id -g) localhost/pokerogue` -6. Visit `http://localhost:8000/` +4. `podman cp temp-pokerogue:/app/public/locales ./public/` +5. `podman rm temp-pokerogue` +6. `podman run --rm -p 8000:8000 -v $(pwd):/app:Z --userns=keep-id -u $(id -u):$(id -g) localhost/pokerogue` +7. Visit `http://localhost:8000/` Note: 1. Steps 2,3,4 are required because mounting working directory without installed `node_modules/` locally will be empty, this way we prevent it by copying them from the container itself to local directory -2. `podman run` may take a couple of minutes to mount the working directory \ No newline at end of file +2. `podman run` may take a couple of minutes to mount the working directory + +### Running tests inside container + +1. `podman run --rm -p 8000:8000 -v $(pwd):/app:Z --userns=keep-id -u $(id -u):$(id -g) localhost/pokerogue2 pnpm test:silent +` \ No newline at end of file From 12aba4ad00d4ff9c66ef7791dc54f2de38e1f5f7 Mon Sep 17 00:00:00 2001 From: Domagoj Date: Sat, 16 Aug 2025 15:18:58 +0200 Subject: [PATCH 8/9] Remove Dockerfile comment --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b186b258f7..ddb865b4831 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ COPY . . # Copy package files COPY package.json pnpm-lock.yaml ./ -# Install all dependencies, skipping postinstall +# Install all dependencies RUN --mount=type=cache,target=/home/appuser/.pnpm-store \ pnpm install --frozen-lockfile && \ rm -rf /home/appuser/.pnpm-store/* @@ -44,4 +44,4 @@ ENV VITE_BYPASS_LOGIN=1 \ EXPOSE $PORT # Start the app in development mode -CMD ["pnpm", "run", "start:podman"] \ No newline at end of file +CMD ["pnpm", "run", "start:podman"] From ba570bf6f7525d4da762289259307cb9f5242bcf Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Sat, 16 Aug 2025 11:51:48 -0700 Subject: [PATCH 9/9] Re-add `pnpm` version to Github Pages workflow --- .github/workflows/github-pages.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 994409bbb30..1588a15afeb 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -37,6 +37,8 @@ jobs: - name: Install pnpm uses: pnpm/action-setup@v4 + with: + version: 10 - name: Setup Node 22.14.1 uses: actions/setup-node@v4