From bc92824b4c4b115e700fd805656b87f04ffedec4 Mon Sep 17 00:00:00 2001 From: Domagoj Date: Sat, 26 Jul 2025 10:23:11 +0200 Subject: [PATCH 1/4] 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/4] 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/4] 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/4] 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/` -