feat(infra): add Docker, Compose and Dev Container support for Tauri#143
feat(infra): add Docker, Compose and Dev Container support for Tauri#143dharapandya85 wants to merge 1 commit into
Conversation
|
@abhishek-nexgen-dev , please review. |
There was a problem hiding this comment.
Code Review
This pull request introduces a Tauri development environment using Docker and VS Code Dev Containers, adding configuration files such as a Dockerfile, docker-compose.yml, and devcontainer.json, alongside minor package dependency updates. The review feedback highlights critical improvements for the Docker setup, including running the container as a non-root user with proper directory ownership to avoid permission issues, resolving a package manager mismatch between npm and pnpm, disabling hardware acceleration to prevent GUI rendering issues, and utilizing named volumes to persist Cargo compilation artifacts.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| RUN useradd -ms /bin/bash developer | ||
|
|
||
| WORKDIR /app |
There was a problem hiding this comment.
To avoid permission issues when running the container as a non-root user (especially with host-mounted volumes and Dev Containers), the developer user should own the /app and /usr/local/cargo directories. This allows us to run dependency installation and development commands safely without root privileges.
RUN useradd -ms /bin/bash developer && \
mkdir -p /app && \
chown -R developer:developer /app /usr/local/cargo
WORKDIR /app
| COPY --from=dependencies /usr/local/cargo /usr/local/cargo | ||
| COPY --from=dependencies /app /app |
There was a problem hiding this comment.
To ensure the non-root developer user has full read/write access to the Cargo registry and the installed Node.js dependencies, we should copy these directories with the correct ownership using --chown=developer:developer.
COPY --from=dependencies --chown=developer:developer /usr/local/cargo /usr/local/cargo
COPY --from=dependencies --chown=developer:developer /app /app
| #USER developer | ||
|
|
||
| USER root | ||
| RUN mkdir -p /tmp/cargo-target && chmod -R 777 /tmp/cargo-target |
There was a problem hiding this comment.
Instead of running the development container as root, we should use the non-root developer user we created. Running as root can cause files generated inside the container (like node_modules or build artifacts) to be owned by root on the host machine, leading to permission issues.
With the directory permissions set up in the base stage, we can safely switch to USER developer here.
USER root
RUN mkdir -p /tmp/cargo-target && chown -R developer:developer /tmp/cargo-target
USER developer
| EXPOSE 1421 | ||
| EXPOSE 5173 | ||
|
|
||
| CMD ["npm", "run", "tauri", "dev"] No newline at end of file |
There was a problem hiding this comment.
There is a package manager mismatch in the project configuration:
package-lock.jsonis present and modified in this PR, indicating the project usesnpm.- However,
src-tauri/tauri.conf.jsonspecifies"beforeDevCommand": "pnpm dev".
When npm run tauri dev is executed inside the container, Tauri will attempt to run pnpm dev. Since node_modules was populated using npm install in the dependencies stage, running pnpm will cause package resolution issues or trigger an unexpected reinstall.
Please update src-tauri/tauri.conf.json to use npm run dev (and npm run build for beforeBuildCommand) to ensure consistency across the project.
| - CHOKIDAR_USEPOLLING=true | ||
| - CARGO_TARGET_DIR=/tmp/cargo-target |
There was a problem hiding this comment.
When running GUI applications like Tauri (which uses WebKitGTK on Linux) inside a Docker container, hardware acceleration often fails or causes rendering issues (such as a blank white screen) unless a GPU is properly passed through.
Setting WEBKIT_DISABLE_COMPOSITING_MODE=1 disables hardware acceleration and forces software rendering, which is highly recommended for reliable rendering in Docker/Dev Container environments.
- CHOKIDAR_USEPOLLING=true
- WEBKIT_DISABLE_COMPOSITING_MODE=1
- CARGO_TARGET_DIR=/tmp/cargo-target| RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ | ||
| apt-get update && apt-get install -y nodejs |
| RUN npm install -g \ | ||
| pnpm \ | ||
| yarn \ | ||
| @tauri-apps/cli |
There was a problem hiding this comment.
| - cargo-cache:/usr/local/cargo/registry | ||
| - /tmp/cargo-target/ | ||
| - /app/node_modules/ | ||
| - /tmp/.X11-unix:/tmp/.X11-unix |
There was a problem hiding this comment.
Using a named volume for the Cargo target directory instead of an anonymous volume ensures that compiled Rust build artifacts are persisted even when containers are destroyed and recreated. This significantly speeds up subsequent builds by avoiding full recompilations.
- cargo-cache:/usr/local/cargo/registry
- cargo-target:/tmp/cargo-target
- /app/node_modules/
- /tmp/.X11-unix:/tmp/.X11-unix| volumes: | ||
| cargo-cache: | ||
|
No newline at end of file |
|
@dharapandya85 fix these issue |
This PR introduces a complete Docker-based development and deployment environment for Tauri desktop application.
Solves: #72