Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .devcontainer/Dockerfile
Empty file.
19 changes: 19 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "Tauri Dev Environment",
"dockerComposeFile": "../docker/docker-compose.yml",
"service": "tauri-app",
"workspaceFolder": "/app",

"customizations": {
"vscode": {
"extensions": [
"rust-lang.rust-analyzer",
"vadimcn.vscode-lldb",
"tauri-apps.tauri-vscode",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint"
]
}
},
"remoteUser": "developer"
}
17 changes: 17 additions & 0 deletions docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
node_modules
target
dist
build
.cache
.git
.github
.vscode
.idea

*.log
.env
.env.*
.DS_Store

src-tauri/target
coverage
81 changes: 81 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#Base Builder Image
FROM rust:1.88-slim AS base

ENV DEBIAN_FRONTEND=noninteractive

# Install Node.js LTS
RUN apt-get update && apt-get install -y \
curl \
git \
wget \
pkg-config \
build-essential \
libssl-dev \
libgtk-3-dev \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf \
openssl \
ca-certificates \
xdg-utils \
file \
libxdo-dev \
&& rm -rf /var/lib/apt/lists/*

# Install Node.js
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get update && apt-get install -y nodejs
Comment on lines +27 to +28

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Clean up the apt package lists after installing Node.js to keep the Docker image size as small as possible.

RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
    apt-get update && apt-get install -y nodejs && \
    rm -rf /var/lib/apt/lists/*


# Install package managers
RUN npm install -g \
pnpm \
yarn \
@tauri-apps/cli
Comment on lines +31 to +34

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since the container runs the local Tauri CLI via npm run tauri dev (defined in CMD), there is no need to install @tauri-apps/cli globally. Removing it reduces the image build time and size, and prevents potential version mismatch confusion.

RUN npm install -g \
    pnpm \
    yarn


# Create non-root user
RUN useradd -ms /bin/bash developer

WORKDIR /app
Comment on lines +37 to +39

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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



# Dependency Cache Stage
FROM base AS dependencies

COPY package.json ./
COPY package-lock.json* ./
COPY pnpm-lock.yaml* ./
COPY yarn.lock* ./

RUN \
if [ -f package-lock.json ]; then npm install; fi && \
if [ -f pnpm-lock.yaml ]; then pnpm install; fi && \
if [ -f yarn.lock ]; then yarn install; fi

COPY src-tauri/Cargo.toml ./src-tauri/Cargo.toml
COPY src-tauri/Cargo.lock ./src-tauri/Cargo.lock

RUN mkdir -p src-tauri/src && \
echo "fn main() {}" > src-tauri/src/main.rs && \
touch src-tauri/src/lib.rs

RUN cd src-tauri && cargo fetch

# Development Stage
FROM base AS development

COPY --from=dependencies /usr/local/cargo /usr/local/cargo
COPY --from=dependencies /app /app
Comment on lines +67 to +68

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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


WORKDIR /app

#USER developer

USER root
RUN mkdir -p /tmp/cargo-target && chmod -R 777 /tmp/cargo-target
Comment on lines +72 to +75

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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 1420
EXPOSE 1421
EXPOSE 5173

CMD ["npm", "run", "tauri", "dev"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There is a package manager mismatch in the project configuration:

  1. package-lock.json is present and modified in this PR, indicating the project uses npm.
  2. However, src-tauri/tauri.conf.json specifies "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.

43 changes: 43 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
services:
tauri-app:
build:
context: ..
dockerfile: docker/Dockerfile
target: development

container_name: tauri-dev

working_dir: /app

environment:
- DISPLAY=${DISPLAY}
- WAYLAND_DISPLAY=${WAYLAND_DISPLAY}
- XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR}
- RUST_BACKTRACE=1
- NODE_ENV=development
- CHOKIDAR_USEPOLLING=true
- CARGO_TARGET_DIR=/tmp/cargo-target
Comment on lines +18 to +19

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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


volumes:
- ..:/app
- cargo-cache:/usr/local/cargo/registry
- /tmp/cargo-target/
- /app/node_modules/
- /tmp/.X11-unix:/tmp/.X11-unix
Comment on lines +23 to +26

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


ports:
- "1420:1420"
- "1421:1421"
- "5173:5173"

stdin_open: true
tty: true

networks:
- tauri-network
networks:
tauri-network:

volumes:
cargo-cache:

Comment on lines +41 to +43

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Declare the cargo-target named volume to persist Rust compilation artifacts across container lifecycles.

volumes:
  cargo-cache:
  cargo-target:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty file added docker/scripts/build.sh
Empty file.
Empty file added docker/scripts/dev.sh
Empty file.
29 changes: 1 addition & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@playwright/test": "^1.60.0",
"@tailwindcss/typography": "^0.5.19",
"@tailwindcss/vite": "^4.3.0",
"@tauri-apps/cli": "2.10.1",
"@tauri-apps/cli": "^2.10.1",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
"@testing-library/user-event": "^14.6.1",
Expand Down