-
Notifications
You must be signed in to change notification settings - Fork 17
feat(docker): add containerized support for dev and deployment [signoff] #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| target/ | ||
| **/*.backup | ||
| **/*.jsonl | ||
| .DS_Store | ||
| *.swp | ||
| *.swo | ||
|
|
||
| # Secrets and credentials | ||
| .env | ||
| .env.* | ||
| *.pem | ||
| *.key | ||
| *.p12 | ||
| environments.json | ||
|
|
||
| # IDE | ||
| .idea/ | ||
| .vscode/ | ||
|
|
||
| # Logs and OS artifacts | ||
| *.log | ||
| Thumbs.db | ||
|
|
||
| # Docker | ||
| .dockerignore | ||
| docker/ | ||
| *.md | ||
| .git | ||
| .github |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # OpenVTC in Docker | ||
|
|
||
| The `docker` folder contains `Dockerfile`s that can be used for generating a build environment and a slim, deployable OpenVTC container. | ||
|
|
||
| ## Containerized deployment | ||
|
|
||
| To build the OpenVTC containerized deployment: | ||
|
|
||
| ```bash | ||
| docker build -t openvtc -f ./docker/Dockerfile . | ||
| ``` | ||
|
|
||
| To run OpenVTC in the container: | ||
|
|
||
| ```bash | ||
| docker run \ | ||
| --rm \ | ||
| -ti \ | ||
| -v "${PWD}/.vscode/data/root:/root" \ | ||
| --network host \ | ||
| openvtc | ||
| ``` | ||
|
|
||
| ## Containerized build environment | ||
|
|
||
| To build the container for development: | ||
|
|
||
| ```bash | ||
| docker build -t openvtc-builder -f ./docker/builder.Dockerfile . | ||
| ``` | ||
|
|
||
| To utilize cargo inside the build environment as your current user, while keeping the cargo cache and user home directory in a centralized folder under `.vscode/data`, use: | ||
|
|
||
| ```bash | ||
| alias cargo='docker run --rm -ti -v "/etc/passwd:/etc/passwd:ro" -v "${PWD}/.vscode/data/home:${HOME}" -v "${PWD}:${PWD}" -w "${PWD}" -e CARGO_HOME=${HOME}/cargo --user $(id -u):$(id -g) -e HOME=${HOME} --network host openvtc-builder cargo' | ||
| ``` | ||
|
|
||
| From here out, all use of `cargo` will work just like using a standard Rust dev environment. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| FROM rust:1 AS builder | ||
|
|
||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| RUN \ | ||
| addgroup --system messagebus &&\ | ||
| apt update &&\ | ||
| apt install -y libdbus-1-dev pkg-config libpcsclite-dev | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: prefer |
||
|
|
||
| ADD . /build | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two notes here:
|
||
| WORKDIR /build | ||
|
|
||
| # Cache a build layer for downloads | ||
| RUN cargo fetch | ||
| RUN cargo build | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This builds a debug binary, so the "slim deployment image" ships an unoptimized, symbol-heavy build. Suggest: RUN cargo build --release -p openvtcand copying from |
||
|
|
||
| # Create the actual image | ||
| FROM debian:trixie-slim | ||
| ARG DEBIAN_FRONTEND=noninteractive | ||
| RUN \ | ||
| apt-get update &&\ | ||
| apt-get install -y ca-certificates libpcsclite1 &&\ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suspected blocker: the runtime image is likely missing Suggested fix: add docker run --rm --entrypoint ldd openvtc /openvtc(no |
||
| apt-get clean &&\ | ||
| rm -rf /var/lib/apt/lists/* | ||
| COPY --from=builder /build/target/debug/openvtc /openvtc | ||
| WORKDIR /data | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ENTRYPOINT ["/openvtc"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| FROM rust:1 | ||
|
|
||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| RUN \ | ||
| addgroup --system messagebus &&\ | ||
| apt update &&\ | ||
| apt install -y libdbus-1-dev pkg-config libpcsclite-dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move the persistent-data path out of
.vscode/— that's a VS Code settings directory, and users without VS Code (or with it, syncing settings) will find app data hidden there surprising. Something like.docker-data/in the repo (gitignored) or~/.openvtc-docker/would be cleaner. Same applies to the.vscode/data/homepath in thecargoalias below. Whatever directory is chosen should be added to.gitignore, since running the deploy image as root leaves root-owned files that pollutegit status.Also worth a note that
--network hostbehaves differently on Docker Desktop (macOS/Windows), which matters since this tool talks to live VTA/VTC services.