build(docker): add Dockerfile for building a server image - #641
Conversation
Multi-stage build: compiles aw-webui and aw-server, then ships only the release binary on debian:bookworm-slim with libssl3. Only aw-server is built, not aw-sync: on Linux the latter pulls in openssl with the "vendored" feature and compiles OpenSSL from source, which is not needed by the image.
| 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 - && \ |
There was a problem hiding this comment.
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!
|
|
||
| EXPOSE 5600 | ||
|
|
||
| CMD ["aw-server-rust"] |
There was a problem hiding this comment.
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.
Greptile SummaryAdds a documented multi-stage Docker build for aw-server-rust.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the floating installer was replaced with an official Node image, and the runtime now launches under the unprivileged aw user with writable HOME-based application paths. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
S[Source tree and initialized aw-webui submodule] --> N[Node 22 stage]
N -->|Node and npm| B[Rust builder stage]
B -->|make aw-server| A[Release server binary with embedded web UI]
A --> R[Debian Bookworm slim runtime]
R --> U[Run as unprivileged user aw]
U --> D[(Persistent ActivityWatch datastore)]
Reviews (2): Last reviewed commit: "Merge branch 'ActivityWatch:master' into..." | Re-trigger Greptile |
|
We have rejected similar PRs in the past, as the Dockerfiles aren't being used by maintainers or in CI and so not something we want to maintain or bless/suggest we support. If you explain your usecase I might change my mind. |
Fair enough — I understand not wanting to bless or maintain something you Use case: I run aw-server-rust as an always-on central instance on a Why this might matter to the project: the absence of a Dockerfile What I'm not asking for: no official image on Docker Hub, no release To address the maintenance concern, I'm happy to do any of:
One thing the containerized build surfaced, incidentally: If the answer is still no, that's completely fine — I'll keep it in my That's a very nice project! Congrats! |
|
@almirb Putting it in |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #641 +/- ##
==========================================
+ Coverage 70.81% 75.96% +5.14%
==========================================
Files 51 63 +12
Lines 2916 5105 +2189
==========================================
+ Hits 2065 3878 +1813
- Misses 851 1227 +376 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Get Node from the official image instead of piping the NodeSource setup script into a root shell: nothing fetched at build time now runs as root in the stage whose artifacts end up in the final image. Run the server as the unprivileged user `aw` (uid/gid 10001) instead of root, which moves the datastore to /home/aw/.local/share/activitywatch. Move the Dockerfile into scripts/ and update the README accordingly.
Done! Could you check it again? Thanks! |
|
@greptileai review |
Multi-stage build: compiles aw-webui and aw-server, then ships only the release binary on debian:bookworm-slim with libssl3.
Only aw-server is built, not aw-sync: on Linux the latter pulls in openssl with the "vendored" feature and compiles OpenSSL from source, which is not needed by the image.