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
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
target/
dist/
aw-webui/dist/
aw-webui/node_modules/
**/node_modules/
.cov/
coverage-html/
.serena/
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Build stage: aw-webui (node) + aw-server (rust, with the webui embedded via rust-embed)
FROM rust:1-bookworm AS builder

RUN apt-get update -qq -y && \
apt-get install -qq -y --no-install-recommends \
build-essential pkg-config libssl-dev ca-certificates curl git make gnupg && \
curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 security Unverified installer controls build artifacts

When the floating NodeSource endpoint is compromised, intercepted, or changed unexpectedly, its response executes directly as root in the builder stage and can modify the server or web assets copied into the runtime image, causing the published image to contain unreviewed code. How this was verified: The remote response runs before make aw-server in the same builder stage whose outputs are copied into the final image.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

apt-get install -qq -y --no-install-recommends nodejs && \
rm -rf /var/lib/apt/lists/*

WORKDIR /app/aw-server-rust
COPY . .

# `make aw-server` builds the webui (aw-webui/dist) before cargo, so that
# aw-server's build.rs can embed the assets into the binary.
# We avoid the `build` target, which also builds aw-sync: that binary pulls in
# openssl with the "vendored" feature (builds OpenSSL from source) and is not
# used by this image.
RUN make aw-server

FROM debian:bookworm-slim

RUN apt-get update -qq -y && \
apt-get install -qq -y --no-install-recommends \
libssl3 && \
rm -rf /var/lib/apt/lists/*

COPY --from=builder /app/aw-server-rust/target/release/aw-server /usr/local/bin/aw-server-rust
COPY --from=builder /app/aw-server-rust/aw-webui/dist /usr/local/share/aw-webui

EXPOSE 5600

CMD ["aw-server-rust"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 security Server runs as root

The runtime stage has no USER directive, so the documented network-facing server and its datastore operations run as UID 0; this unnecessarily expands the impact of a process compromise and creates root-owned files on bind-mounted storage. How this was verified: The final stage launches aw-server-rust without changing users, and the application does not drop privileges.

35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,41 @@ cargo run --bin aw-server

*NOTE:* This will start aw-server-rust in testing mode (on port 5666 instead of port 5600).

### Docker

A multi-stage `Dockerfile` is included. It builds the web UI and the server, and
produces a slim Debian-based image containing only the `aw-server` binary (the
web UI assets are embedded into it at compile time).

The `aw-webui` submodule must be initialized before building:

```sh
git submodule update --init --recursive
docker build -t aw-server-rust:local .
```

Run it with:

```sh
docker run -d --name aw-server-rust \
-p 5600:5600 \
-v aw-server-rust-data:/root/.local/share/activitywatch \
aw-server-rust:local aw-server-rust --host 0.0.0.0
```

Notes:

- The server binds to `127.0.0.1` by default, which is unreachable from outside
the container. Pass `--host 0.0.0.0` (as above) to make it reachable.
- The database lives in `/root/.local/share/activitywatch/aw-server-rust`.
Mount a volume there to keep it across container recreations.
- The image only ships `aw-server`. The `aw-sync` binary is deliberately not
built, since on Linux it pulls in OpenSSL with the `vendored` feature and
compiles it from source.
- `docker build` produces an image for the architecture of the machine running
it. To target a different one, use
`docker buildx build --platform linux/amd64 ...`.

### Configuration

The server reads its configuration from `~/.config/activitywatch/aw-server-rust/config.toml` (or `config-testing.toml` in testing mode).
Expand Down