Skip to content

Commit 3d1f029

Browse files
authored
Update containerization (#10)
This PR: * Updates the Docker containerization to use our tooling (UV and Python 3.13). * Updates the Dockerfile to use build stages. * Adds Compose Watch support to the docker containerization, which enables seamless containerized DX.
1 parent 006cd53 commit 3d1f029

File tree

8 files changed

+106
-73
lines changed

8 files changed

+106
-73
lines changed

.Dockerignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.dockerignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Git
2+
.git
3+
.gitignore
4+
# Python
5+
.venv/
6+
__pycache__/
7+
# Temporary unit testing artefacts
8+
_trial_temp/
9+
.coverage
10+
*.py,cover
11+
# Docker
12+
.Dockerignore
13+
Dockerfile
14+
compose.yml
15+
# Documentation
16+
readme.md

Dockerfile

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
1-
FROM ubuntu:focal
2-
3-
ENV DEBIAN_FRONTEND=noninteractive
4-
5-
RUN apt-get -y update && apt-get -y upgrade
6-
7-
RUN apt-get install -y -q tini curl python3 python3-pip
8-
9-
ENV PYTHONDONTWRITEBYTECODE 1
10-
11-
ENV PYTHONUNBUFFERED 1
12-
13-
WORKDIR /usr/src/app
14-
15-
ADD requirements.txt /usr/src/app
16-
17-
RUN pip3 install --no-cache-dir -r requirements.txt
18-
19-
ADD . /usr/src/app
20-
21-
RUN useradd remote
22-
23-
USER remote
24-
25-
EXPOSE 6837
26-
27-
ENTRYPOINT ["tini", "--", "python3", "server.py", "--certificate=certificate/cert", "--privkey=certificate/key", "--chain=certificate/chain"]
1+
FROM ghcr.io/astral-sh/uv:0.8.2-python3.13-alpine
2+
3+
# We need to set this here even though it is default,
4+
# because if watch is enabled, this part of the Dockerfile may be re-run as remoteUser
5+
# which doesn't have the necessary permissions to update bind mounts.
6+
USER root
7+
8+
# Increases performance, but slows down start-up time
9+
ENV UV_COMPILE_BYTECODE=1
10+
# Keeps Python from buffering stdout and stderr
11+
# to avoid situations where the application crashes without emitting any logs due to buffering.
12+
ENV PYTHONUNBUFFERED=1
13+
# Copy from the cache instead of linking since it's a mounted volume
14+
ENV UV_LINK_MODE=copy
15+
16+
WORKDIR /app
17+
18+
# Install dependencies
19+
RUN --mount=type=cache,target=/root/.cache/uv \
20+
--mount=type=bind,source=uv.lock,target=uv.lock \
21+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
22+
uv sync --locked --no-install-project --no-dev
23+
24+
# Copy over the server
25+
COPY . /app
26+
27+
# Make sure everything is synched
28+
RUN --mount=type=cache,target=/root/.cache/uv \
29+
uv sync --locked
30+
31+
RUN addgroup -S remotegroup && adduser -S remoteuser -G remotegroup
32+
USER remoteuser
33+
EXPOSE 6837
34+
# Run the server
35+
CMD ["uv", "run", "server.py"]

compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
services:
2+
remote_server:
3+
build: .
4+
ports:
5+
- "6837:6837"
6+
develop:
7+
watch:
8+
# Restart whenever code changes are detected
9+
- action: sync+restart
10+
path: .
11+
target: /app
12+
ignore:
13+
- .venv
14+
- action: rebuild
15+
path: ./uv.lock

docker-compose.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "remote-server"
33
version = "0.1.0"
44
description = "NVDA Remote Access remote relay server."
55
readme = "README.md"
6-
requires-python = "~=3.13"
6+
requires-python = "~=3.13.0"
77
dependencies = [
88
"pyopenssl~=25.1",
99
"service-identity~=24.2",

readme.md

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
1-
# NVDA Remote Server Relay
2-
3-
This is a simple server used to relay connections for [NVDA Remote](https://nvdaremote.com)
4-
5-
## Basic Usage
6-
7-
This is currently only tested on Linux.
8-
9-
1. [Install uv](https://docs.astral.sh/uv/getting-started/installation/)
10-
2. Obtain your TLS certificates.
11-
- By default, the server looks for the certificate at `./cert`, the private key at `./privkey`, and the chain of trust at `./chain`.
12-
- TBD - update documentation on this/remove this feature in favour of using the web server to handle TLS
13-
3. run the server with `uv run server.py`.
14-
15-
## Development
16-
17-
This project uses [pre-commit](https://pre-commit.com/) hooks to help ensure code quality.
18-
These run automatically on pull requests, however it is still recommended to set them up locally.
19-
20-
21-
```sh
22-
uvx pre-commit install
23-
```
24-
25-
## Docker
26-
27-
```sh
28-
docker-compose up --build
29-
```
30-
31-
32-
This will expose the server on port 6837, the default.
33-
You must create a folder called certificate along-side the docker-compose.yml which contains the certificate, private key, and root chain named as cert, key, and chain respectively.
1+
# NVDA Remote Server Relay
2+
3+
This is a simple server used to relay connections for [NVDA Remote](https://nvdaremote.com)
4+
5+
## Basic Usage
6+
7+
This is currently only tested on Linux.
8+
9+
1. [Install uv](https://docs.astral.sh/uv/getting-started/installation/)
10+
2. Obtain your TLS certificates.
11+
- By default, the server looks for the certificate at `./cert`, the private key at `./privkey`, and the chain of trust at `./chain`.
12+
- TBD - update documentation on this/remove this feature in favour of using the web server to handle TLS
13+
3. run the server with `uv run server.py`.
14+
15+
## Development
16+
17+
This project uses [pre-commit](https://pre-commit.com/) hooks to help ensure code quality.
18+
These run automatically on pull requests, however it is still recommended to set them up locally.
19+
20+
```sh
21+
uvx pre-commit install
22+
```
23+
24+
## Docker
25+
26+
To run in Docker, use `docker compose`:
27+
28+
```sh
29+
docker compose up
30+
```
31+
32+
This will expose the server on port 6837, the default.
33+
34+
The project is pre-configured to support [Compose Watch](https://docs.docker.com/compose/how-tos/file-watch) to make developing in Docker easier.
35+
To enable Watch, either press `w` when `docker compose up` has completed building and starting the container; or run `docker compose watch` to avoid mixing the application and Compose Watch logs.
36+
37+
* Changes will be synchronised and the server restarted whenever the code changes.
38+
* Changes will be synchronised and the image rebuilt whenever dependencies change.

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)