From be775d4675b19b7f033c01f6826da11b16d7288b Mon Sep 17 00:00:00 2001 From: Nicholas Rodrigues Lordello Date: Fri, 3 Jul 2026 07:56:25 +0200 Subject: Improve Locale Support Previously, the devbox user would default to the `POSIX` locale which meant that a lot of minor things around UTF-8 would not work. We now update the locale to use one with UTF-8 support; note that we just use the minimal C locale instead of building one. Users can (if they chose) use something like `dpkg-reconfigure locales` and `update-locale` in order to modify their default locale if they want something else specific. Additionally, get rid of the annoying known hosts warning, by keeping a devbox specific known hosts file. --- .gitignore | 1 + Containerfile | 4 ++++ dbx | 3 ++- dbx-enter | 2 +- dbx-proxy | 17 +++++++++++++++++ ssh/config.in | 2 +- 6 files changed, 26 insertions(+), 3 deletions(-) create mode 100755 dbx-proxy diff --git a/.gitignore b/.gitignore index 006e32b..0f8e6ab 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ custom/extra-packages custom/post-install custom/skel/ ssh/*.config +ssh/*.known_hosts ssh/id_* diff --git a/Containerfile b/Containerfile index 24698e9..9f250dd 100644 --- a/Containerfile +++ b/Containerfile @@ -7,6 +7,7 @@ RUN touch /run/.dbxenv RUN rm /etc/apt/apt.conf.d/docker-* && \ apt-get update && \ apt-get install -y \ + locales \ openssh-server \ sudo \ tini \ @@ -14,6 +15,9 @@ RUN rm /etc/apt/apt.conf.d/docker-* && \ apt-get clean && \ rm -dr /var/lib/apt/lists/* +# Configure locale with UTF-8 support +RUN update-locale LANG=C.UTF-8 LC_ALL=C.UTF-8 + # Configure SSH server COPY ssh/id_ed25519.pub /etc/ssh/authorized_keys RUN echo "StreamLocalBindUnlink yes" >> /etc/ssh/sshd_config && \ diff --git a/dbx b/dbx index 993ddda..3402133 100755 --- a/dbx +++ b/dbx @@ -13,6 +13,7 @@ dbx - containerized development environments USAGE: dbx create creates the devbox dbx [enter] enters the devbox + dbx proxy PORT proxies a devbox port to the host dbx start starts the devbox dbx stop stops the devbox EOF @@ -22,7 +23,7 @@ cmd="${1:-enter}" shift || true case "$#:$cmd" in - 0:create|0:enter|0:start|0:stop) + 0:create|0:enter|1:proxy|0:start|0:stop) "$root/dbx-$cmd" "$@" ;; *) diff --git a/dbx-enter b/dbx-enter index 88db503..49078b4 100755 --- a/dbx-enter +++ b/dbx-enter @@ -8,4 +8,4 @@ root="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" machine="${DBX_MACHINE:-dbx}" "$root/dbx-start" -exec ssh -F "$root/ssh/$machine.config" "$machine" +exec ssh "$machine" -F "$root/ssh/$machine.config" diff --git a/dbx-proxy b/dbx-proxy new file mode 100755 index 0000000..67e0456 --- /dev/null +++ b/dbx-proxy @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-only + +set -euo pipefail + +if [[ $# -ne 1 ]]; then + echo "ERROR: missing port to proxy" >&2 + exit 1 +fi + +root="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" +machine="${DBX_MACHINE:-dbx}" +port="$1" + +"$root/dbx-start" +exec ssh "$machine" -F "$root/ssh/$machine.config" \ + -L "localhost:$port:localhost:$port" -N diff --git a/ssh/config.in b/ssh/config.in index 294754e..fbcbc40 100644 --- a/ssh/config.in +++ b/ssh/config.in @@ -3,4 +3,4 @@ Host $MACHINE IdentitiesOnly yes IdentityFile $ROOT/ssh/id_ed25519 StrictHostKeyChecking no - UserKnownHostsFile /dev/null + UserKnownHostsFile $ROOT/ssh/$MACHINE.known_hosts -- cgit v1.2.3