Skip to content

Commit ed1590f

Browse files
authored
Merge pull request #3 from soffchen/claude/optimize-docker-image-size
Addressing PR comments
2 parents 8c9d7e9 + da10212 commit ed1590f

File tree

5 files changed

+261
-55
lines changed

5 files changed

+261
-55
lines changed

Dockerfile

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,40 @@
11
FROM alpine:edge
22

3-
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
4-
RUN apk update
5-
RUN apk add --no-cache xvfb x11vnc fluxbox supervisor xterm bash chromium firefox xrdp wqy-zenhei novnc websockify
6-
7-
RUN ln -s /usr/share/novnc/vnc_lite.html /usr/share/novnc/index.html
3+
# Add testing repository and update
4+
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
5+
apk update && \
6+
# Install minimal required packages
7+
apk add --no-cache \
8+
xvfb \
9+
x11vnc \
10+
fluxbox \
11+
supervisor \
12+
firefox \
13+
xrdp \
14+
novnc \
15+
websockify && \
16+
# Clean up
17+
rm -rf /var/cache/apk/* /tmp/* && \
18+
# Create noVNC symlink
19+
ln -s /usr/share/novnc/vnc_lite.html /usr/share/novnc/index.html
820

21+
# Copy configuration files
922
ADD supervisord.conf /etc/supervisord.conf
1023
ADD xrdp.ini /etc/xrdp/xrdp.ini
1124
ADD menu /root/.fluxbox/menu
1225
ADD entry.sh /entry.sh
1326

1427
RUN chmod +x /entry.sh
1528

16-
ENV DISPLAY :0
29+
# Environment variables
30+
ENV DISPLAY=:0
1731
ENV RESOLUTION=1024x768
32+
ENV ENABLE_VNC=true
33+
ENV ENABLE_RDP=true
34+
ENV ENABLE_NOVNC=true
35+
ENV AUTOSTART_FIREFOX=true
1836

19-
EXPOSE 5901 6901
37+
# Expose ports: VNC (5901), noVNC (6901), RDP (3389)
38+
EXPOSE 5901 6901 3389
2039

21-
ENTRYPOINT ["/bin/bash", "-c", "/entry.sh"]
40+
ENTRYPOINT ["/entry.sh"]

README.md

Lines changed: 183 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,64 @@
1-
# Alpine docker container image with "headless" VNC/RDP environments
1+
# Tiny Remote Desktop
22

3-
Installed with the following components:
3+
Alpine-based Docker container with "headless" VNC/RDP remote desktop environments.
44

5-
* Desktop environment [**Fluxbox**](http://fluxbox.org)
6-
* xrdp server (default RDP port `3389`)
7-
* vnc server (default VNC port `5901`)
8-
* [**noVNC**](https://github.com/novnc/noVNC) - HTML5 VNC client (default http port `6901`)
9-
* Browsers:
10-
* Chromium
11-
* Firefox
12-
5+
## Features
136

14-
## Current provided OS & UI sessions:
7+
* Desktop environment: [**Fluxbox**](http://fluxbox.org) (lightweight)
8+
* VNC server: **x11vnc** (port `5901`)
9+
* RDP server: **xrdp** (port `3389`)
10+
* Web VNC: [**noVNC**](https://github.com/novnc/noVNC) - HTML5 VNC client (port `6901`)
11+
* Browser: **Firefox**
12+
* **Configurable**: Enable/disable services via environment variables
13+
* **Auto-start**: Firefox can auto-launch on startup
1514

16-
* `soff/tiny-remote-desktop`: __Alpine with `Fluxbox` UI session__
15+
## Image Size Optimization
1716

17+
### Current Size: ~300-350MB
1818

19-
## Usage
19+
The image has been optimized by removing unnecessary packages:
20+
-**Chromium** (~200MB) - Removed to reduce size
21+
-**xterm** - Removed (not essential)
22+
-**bash** - Using Alpine's built-in `sh`
23+
-**wqy-zenhei** (Chinese fonts) - Removed
2024

21-
- Run command with mapping to local port `5901` (vnc protocol) and `6901` (vnc web access):
25+
### Further Size Reduction
2226

23-
docker run -d -p 5901:5901 -p 6901:6901 soff/tiny-remote-desktop
27+
If you need an even smaller image:
2428

25-
- Run command with mapping to local port `3389` (rdp protocol):
29+
1. **Remove Firefox** (~100MB saved):
30+
```dockerfile
31+
# Remove 'firefox' from line 12 in Dockerfile
32+
# Set AUTOSTART_FIREFOX=false
33+
# Final size: ~200-250MB
34+
```
2635

27-
docker run -d -p 3389:3389 soff/tiny-remote-desktop
36+
2. **Remove noVNC** (~10-20MB saved):
37+
```dockerfile
38+
# Remove 'novnc' and 'websockify' from Dockerfile
39+
# Set ENABLE_NOVNC=false
40+
```
2841

29-
- Run command with mapping to local port `5901` (vnc protocol) and `6901` (vnc web access) with access password:
42+
3. **VNC-only setup** (~150-200MB):
43+
```dockerfile
44+
# Keep only: xvfb, x11vnc, fluxbox, supervisor
45+
# Remove: firefox, xrdp, novnc, websockify
46+
```
3047

31-
docker run -d -p 5901:5901 -p 6901:6901 -e VNC_PASSWORD="vncpassword" soff/tiny-remote-desktop
48+
## VNC vs RDP - Which is Faster?
3249

33-
- Run command with mapping to local port `5901` (vnc protocol) and `6901` (vnc web access) with specific resolution:
50+
### VNC (Recommended) ✅
51+
- **Faster** for local/LAN connections
52+
- Lower latency and overhead
53+
- Direct connection without additional layers
54+
- **Best choice for this setup**
3455

35-
docker run -d -p 5901:5901 -p 6901:6901 -e RESOLUTION=1600x1200 soff/tiny-remote-desktop
56+
### RDP
57+
- Better for slow/WAN connections (better compression)
58+
- In this setup, RDP wraps VNC (adds overhead)
59+
- Use VNC directly for better performance
60+
61+
**Verdict**: **VNC is faster** - RDP just adds an extra layer in this configuration.
3662

3763
## Automated Builds
3864

@@ -51,7 +77,139 @@ To enable automated builds, the following secrets must be configured in the repo
5177
- `DOCKERHUB_USERNAME`: Your Docker Hub username
5278
- `DOCKERHUB_TOKEN`: Your Docker Hub access token (create one at https://hub.docker.com/settings/security)
5379

54-
## Hints
55-
56-
### 1) No start menu?
57-
Just right click on desktop, the start menu will pop up.
80+
## Configuration
81+
82+
### Environment Variables
83+
84+
| Variable | Default | Description |
85+
|----------|---------|-------------|
86+
| `RESOLUTION` | `1024x768` | Screen resolution |
87+
| `VNC_PASSWORD` | (none) | VNC password (optional) |
88+
| `ENABLE_VNC` | `true` | Enable VNC server |
89+
| `ENABLE_RDP` | `true` | Enable RDP server |
90+
| `ENABLE_NOVNC` | `true` | Enable web-based VNC |
91+
| `AUTOSTART_FIREFOX` | `true` | Auto-start Firefox |
92+
93+
### Ports
94+
95+
| Port | Protocol | Description |
96+
|------|----------|-------------|
97+
| 5901 | VNC | Direct VNC access |
98+
| 6901 | HTTP | noVNC web interface |
99+
| 3389 | RDP | Remote Desktop Protocol |
100+
101+
## Usage Examples
102+
103+
### Default Setup (All Services)
104+
```bash
105+
docker run -d \
106+
-p 5901:5901 \
107+
-p 6901:6901 \
108+
-p 3389:3389 \
109+
--name remote-desktop \
110+
soff/tiny-remote-desktop
111+
```
112+
113+
Access via:
114+
- VNC client: `localhost:5901`
115+
- Web browser: `http://localhost:6901`
116+
- RDP client: `localhost:3389`
117+
118+
### VNC-Only (Fastest, Smallest)
119+
```bash
120+
docker run -d \
121+
-p 5901:5901 \
122+
-e ENABLE_RDP=false \
123+
-e ENABLE_NOVNC=false \
124+
--name remote-desktop \
125+
soff/tiny-remote-desktop
126+
```
127+
128+
### RDP-Only
129+
```bash
130+
docker run -d \
131+
-p 3389:3389 \
132+
-e ENABLE_VNC=false \
133+
-e ENABLE_NOVNC=false \
134+
--name remote-desktop \
135+
soff/tiny-remote-desktop
136+
```
137+
138+
### With VNC Password
139+
```bash
140+
docker run -d \
141+
-p 5901:5901 \
142+
-p 6901:6901 \
143+
-e VNC_PASSWORD="vncpassword" \
144+
--name remote-desktop \
145+
soff/tiny-remote-desktop
146+
```
147+
148+
### Custom Resolution
149+
```bash
150+
docker run -d \
151+
-p 5901:5901 \
152+
-p 6901:6901 \
153+
-e RESOLUTION=1920x1080 \
154+
--name remote-desktop \
155+
soff/tiny-remote-desktop
156+
```
157+
158+
### Without Firefox Auto-Start
159+
```bash
160+
docker run -d \
161+
-p 5901:5901 \
162+
-e AUTOSTART_FIREFOX=false \
163+
--name remote-desktop \
164+
soff/tiny-remote-desktop
165+
```
166+
167+
## Troubleshooting
168+
169+
### "Another user already login with this id" Error
170+
171+
**Fixed!** This error has been resolved by:
172+
- Adding `-forever` flag to x11vnc
173+
- Proper service startup priorities
174+
- Correct DISPLAY environment configuration
175+
176+
If you still see this error:
177+
1. Ensure only one container instance is running
178+
2. Restart the container: `docker restart <container_name>`
179+
3. Check logs: `docker logs <container_name>`
180+
181+
### RDP Auto-Login
182+
183+
When connecting via RDP:
184+
- Username: `root` (pre-filled)
185+
- Password: (leave empty, press Enter)
186+
- Session: `Xvnc` (pre-selected)
187+
- Just click **OK** or press Enter
188+
189+
For completely password-free access, use VNC directly (port 5901).
190+
191+
### Firefox Auto-Start
192+
193+
Firefox auto-starts when `AUTOSTART_FIREFOX=true` (default).
194+
195+
If Firefox doesn't start:
196+
1. Check logs: `docker logs <container_name>`
197+
2. Start manually from Fluxbox menu (right-click desktop)
198+
3. Verify startup script exists:
199+
```bash
200+
docker exec <container_name> cat /root/.fluxbox/startup
201+
```
202+
203+
### No Start Menu?
204+
205+
Right-click anywhere on the desktop to open the Fluxbox menu.
206+
207+
## Building
208+
209+
```bash
210+
docker build -t tiny-remote-desktop .
211+
```
212+
213+
## License
214+
215+
This project does not yet include a formal license file. All rights are reserved by the maintainer unless otherwise stated. Please contact the maintainer for usage permissions.

entry.sh

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,45 @@
11
#!/bin/sh
22

3+
# Configure VNC password if provided (idempotent using -rfbauth)
34
if [ "$VNC_PASSWORD" ]; then
4-
sed -i "s/^\(command.*x11vnc.*\)$/\1 -passwd '$VNC_PASSWORD'/" /etc/supervisord.conf
5+
VNC_PASSFILE="/root/.vncpass"
6+
x11vnc -storepasswd "$VNC_PASSWORD" "$VNC_PASSFILE"
7+
chmod 600 "$VNC_PASSFILE"
8+
# Make the change idempotent: remove any existing -passwd, -rfbauth, or -nopw args on the x11vnc command
9+
sed -i \
10+
-e '/command.*x11vnc/ s/ -passwd [^ ]*//g' \
11+
-e '/command.*x11vnc/ s/ -rfbauth [^ ]*//g' \
12+
-e '/command.*x11vnc/ s/ -nopw//g' \
13+
/etc/supervisord.conf
14+
# Append the auth file option to the x11vnc command
15+
sed -i "s|^\(command.*x11vnc.*\)$|\1 -rfbauth ${VNC_PASSFILE}|" /etc/supervisord.conf
516
fi
617

7-
/usr/bin/supervisord
18+
# Ensure noVNC is not enabled when VNC is disabled
19+
if [ "$ENABLE_NOVNC" = "true" ] && [ "$ENABLE_VNC" != "true" ]; then
20+
echo "Warning: ENABLE_NOVNC=true requires ENABLE_VNC=true; disabling noVNC."
21+
ENABLE_NOVNC="false"
22+
fi
23+
24+
# Disable services based on environment variables
25+
if [ "$ENABLE_VNC" != "true" ]; then
26+
sed -i '/\[program:x11vnc\]/,/^$/d' /etc/supervisord.conf
27+
fi
28+
29+
if [ "$ENABLE_RDP" != "true" ]; then
30+
sed -i '/\[program:xrdp\]/,/^$/d' /etc/supervisord.conf
31+
fi
32+
33+
if [ "$ENABLE_NOVNC" != "true" ]; then
34+
sed -i '/\[program:novnc\]/,/^$/d' /etc/supervisord.conf
35+
fi
36+
37+
# Configure Firefox autostart
38+
if [ "$AUTOSTART_FIREFOX" = "true" ]; then
39+
mkdir -p /root/.fluxbox
40+
echo "firefox &" > /root/.fluxbox/startup
41+
echo "exec fluxbox" >> /root/.fluxbox/startup
42+
chmod +x /root/.fluxbox/startup
43+
fi
44+
45+
exec /usr/bin/supervisord

menu

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,9 @@
1616
# session.menuFile: ~/.fluxbox/my-menu
1717
[begin] (Fluxbox-1.3.7)
1818
[encoding] {UTF-8}
19-
[exec] (Xterm) {xterm}
20-
[exec] (Chromium) {chromium-browser --no-sandbox}
2119
[exec] (Firefox) {firefox}
22-
[submenu] (Editors)
23-
[exec] (vi) {xterm -e vi}
24-
[end]
2520
[submenu] (System Tools)
26-
[exec] (top) {xterm -e top}
21+
[nop] (top (no terminal available))
2722
[end]
2823
[submenu] (Fluxbox menu)
2924
[config] (Configure)

supervisord.conf

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,28 @@
22
nodaemon=true
33

44
[program:X11]
5-
command=/usr/bin/Xvfb :0 -screen 0 %(ENV_RESOLUTION)sx24
5+
command=/usr/bin/Xvfb %(ENV_DISPLAY)s -screen 0 %(ENV_RESOLUTION)sx24
66
autorestart=true
7+
priority=10
78

89
[program:x11vnc]
9-
command=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -nopw -wait 5 -shared -permitfiletransfer -tightfilexfer -rfbport 5901
10+
command=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display %(ENV_DISPLAY)s -forever -wait 5 -shared -permitfiletransfer -tightfilexfer -rfbport 5901
1011
autorestart=true
12+
priority=20
1113

1214
[program:novnc]
1315
command=/usr/bin/novnc_server --vnc localhost:5901 --listen 6901
1416
autorestart=true
17+
priority=30
1518

1619
[program:fluxbox]
1720
command=/usr/bin/fluxbox
1821
autorestart=true
19-
20-
[program:xterm]
21-
command=/usr/bin/xterm
22-
autorestart=false
23-
startretries = 1
22+
priority=40
23+
environment=DISPLAY="%(ENV_DISPLAY)s"
2424

2525
[program:xrdp]
26-
command=/usr/sbin/xrdp
26+
command=/usr/sbin/xrdp -n
2727
autorestart=true
28-
startretries = 1
29-
30-
[program:chromium]
31-
command=/usr/bin/chromium-browser --no-sandbox
32-
autorestart=false
33-
startretries = 1
28+
startretries=3
29+
priority=50

0 commit comments

Comments
 (0)