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.
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "CommDesk Tauri Dev ",
"dockerComposeFile": "../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"
],
"settings": {
"editor.formatOnSave": true,
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
}
}
}
},
"remoteUser": "developer"
}
21 changes: 21 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
node_modules
**/node_modules
src-tauri/target
target
dist
build
.cache
.git
.github
.vscode
.idea

*.log
.env
.env.*
!.env.example
.DS_Store

coverage
test-results
docs
83 changes: 83 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#Base Builder Image
FROM rust:1.88-slim AS base

ENV DEBIAN_FRONTEND=noninteractive \
CARGO_HOME=/usr/local/cargo \
PNPM_HOME=/usr/local/share/pnpm \
PATH=/usr/local/share/pnpm:/usr/local/cargo/bin:$PATH

# Install Node.js LTS
RUN apt-get update && apt-get install -y --no-install-recommends \
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 --no-install-recommends nodejs && \
rm -rf /var/lib/apt/lists/*

# Install package managers
RUN npm install -g \
pnpm \
yarn

# Create non-root user
RUN useradd -ms /bin/bash developer && \
mkdir -p /app "$PNPM_HOME" && \
chown -R developer:developer /app "$CARGO_HOME" "$PNPM_HOME"

WORKDIR /app


# Dependency Cache Stage
FROM base AS dependencies

COPY --chown=developer:devloper \
package.json \
package-lock.json* \
pnpm-lock.yaml* \
yarn.lock* \
./

RUN \
if [ -f pnpm-lock.yaml ]; then pnpm install --frozen-lockfile; \
elif [ -f yarn.lock ]; then yarn install --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
else echo "No lockfile found" && exit 1; fi

COPY --chown=developer:developer src-tauri/Cargo.toml src-tauri/Cargo.lock ./src-tauri/
RUN mkdir -p /app/src-tauri/src && touch /app/src-tauri/src/lib.rs
RUN cd src-tauri && cargo fetch

# Development Stage
FROM base AS development

COPY --from=dependencies --chown=developer:developer /usr/local/cargo /usr/local/cargo
COPY --from=dependencies --chown=developer:developer /usr/local/share/pnpm /usr/local/share/pnpm
COPY --from=dependencies --chown=developer:developer /app /app

#USER developer

USER root
RUN mkdir -p /app/src-tauri/target && \
chown -R developer:developer /app/src-tauri/target && \
chmod -R 777 /app/src-tauri/target

USER developer

EXPOSE 1420
EXPOSE 1421
EXPOSE 5173

CMD ["pnpm", "tauri", "dev"]

FROM dependencies AS builder

COPY --chown=developer:developer . .

RUN if [ -f pnpm-lock.yaml ]; then pnpm tauri build; \
elif [ -f yarn.lock ]; then yarn tauri build; \
else npm run tauri build; fi
40 changes: 40 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
services:
tauri:
build:
context: .
dockerfile: Dockerfile
target: development

container_name: commdesk-dev
working_dir: /app
command: pnpm run dev

volumes:
- type: bind
source: ${PWD}
target: /app

- node_modules:/app/node_modules
- cargo_registry:/usr/local/cargo/registry
- cargo_git:/usr/local/share/pnpm/store
- pnpm_store:/usr/local/share/pnpm/store
- rust_target:/app/src-tauri/target

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

environment:
- TAURI_SKIP_DEVSERVER_CHECK=true

stdin_open: true
tty: true

volumes:
node_modules:
cargo_registry:
cargo-git:
pnpm_store:
rust_target:

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
85 changes: 85 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#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 && \
rm -rf /var/lib/apt/lists/*

# Install package managers
RUN npm install -g \
pnpm \
yarn

# Create non-root user
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 --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 && chown -R developer:developer /tmp/cargo-target

USER developer

EXPOSE 1420
EXPOSE 1421
EXPOSE 5173

CMD ["pnpm", "tauri", "dev"]
46 changes: 46 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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
- WEBKIT_DISABLE_COMPOSITING_MODE=1
- CARGO_TARGET_DIR=/tmp/cargo-target
Comment on lines +18 to +20

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
- node_modules:/app/node_modules/
- cargo-cache:/usr/local/cargo/registry
- cargo-target:/tmp/cargo-target
- /tmp/.X11-unix:/tmp/.X11-unix
Comment on lines +25 to +27

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:
cargo-target:
node_modules:

Comment on lines +42 to +46

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.
Loading