Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .devcontainer/.gitignore
Empty file.
66 changes: 66 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Run inside a recent debian based image with python3, pip3, git and sudo installed
# This is the same as the debian version but used to test against full ubuntu
FROM mcr.microsoft.com/devcontainers/base:noble

# We use 'user' as the name to match what the zhephyr-build image already created
ARG USERNAME=vscode

## Setup a user with sudo support
USER root

# Add core python packages
# libxcb-cursor0 is needed for Qt6
RUN apt-get update && apt-get -y install --no-install-recommends \
python3 python3-pip python3-venv python-is-python3 python3-tk sudo git flatpak libxcb-cursor0 build-essential curl \
openscad

# Create a non-root user if one doesn't exist, and give it sudo rights
RUN if ! id -u ${USERNAME} > /dev/null 2>&1; then \
groupadd --gid 1000 ${USERNAME} && \
useradd --uid 1000 --gid 1000 --create-home --shell /bin/bash ${USERNAME} && \
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USERNAME}-nopasswd; \
fi

USER ${USERNAME}

# Some containers might not have a .local directory at all, don't fail in that case
RUN mkdir -p /home/${USERNAME}/.local/bin

# Add the local bin directory to the PATH. For pipx and flatpacks
ENV PATH="/home/${USERNAME}/.local/bin:$HOME/.local/share/flatpak/exports/bin/:${PATH}"

# Install Siril flat pack (for testing)
# Note: this must be done here, if done in Dockerfile it doesn't work - this env var is a nasty hack to allow
# flatpak inside of Dockerfile.
# https://github.com/flatpak/flatpak/issues/5076
#ENV FLATPAK_SYSTEM_HELPER_ON_SESSION=foo
#RUN flatpak --user remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
#RUN flatpak install --user -y flathub org.siril.Siril`
# Let siril see /tmp
#RUN flatpak --user override --filesystem=/tmp org.siril.Siril

# Pull in the latest openscad
RUN cd /home/${USERNAME}/.local/bin \
&& wget https://files.openscad.org/snapshots/OpenSCAD-2026.01.01.ai30333-x86_64.AppImage \
&& mv OpenSCAD-2026.01.01.ai30333-x86_64.AppImage openscad \
&& chmod +x openscad

USER root

# needed for vhs to make movies

# alas chromium-browser requires snap which is a whole other kettle of fish
# RUN apt-get install -y --no-install-recommends chromium-browser chromium-codecs-ffmpeg

# instead we install chrome - you might need to run the GUI once before using it from VHS
#RUN cd /tmp && \
# wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
# apt install -y ./google-chrome-stable_current_amd64.deb

# We need the docker CLI for build ghcr.io containers
# needed because i'm using old docker commands above - someday move this docker install to top and the update can leave
#RUN apt-get update
#RUN apt-get -y install --no-install-recommends docker.io

# Make container smaller. Do this last, so that if we change the container it is fast to use existing apts
RUN rm -rf /var/lib/apt/lists/*
5 changes: 5 additions & 0 deletions .devcontainer/OpenSCAD.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[User Settings]
// Limit the PolySet cache (geometry cache) to 100MB (default is often higher)
Design/PolySetCacheLimit=102400
// Limit the CGAL cache (boolean operation cache)
Design/CGALCacheLimit=102400
103 changes: 103 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/miniconda
{
// leave anonymous for now: "name": "geeksville-dev",
"build": {
// "context": "..",
"dockerfile": "Dockerfile"
},
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
// add git
"ghcr.io/devcontainers/features/git:1": {},
// add the github cli tool (gh)
"ghcr.io/devcontainers/features/github-cli:1": {},
// use https://just.systems/ for developer scripts via https://github.com/guiyomh/features/tree/main/src/just
// "ghcr.io/guiyomh/features/just:0": {},
// install the podman command (for building ghcr.io containers)
// DOESN'T WORK just do an "apt install docker.io" instead (which does successfully use podman.sock)
// "ghcr.io/devcontainers-extra/features/podman-homebrew:1": {}
},
// "forwardPorts": [5000]
"runArgs": [
"--memory=32g", // openscad needs lots of memory but I don't want to kill my host
"--privileged", // Allow full hw access from host, also allows writing core dump files
// "--network=host", // Use host network rather than our bridged container network
"--ipc=host", // Needed to make python SharedMemory work
"--user=1000:1000",
// Recommended https://rocm.docs.amd.com/projects/install-on-linux/en/docs-6.2.0/how-to/docker.html
//"--security-opt=seccomp=unconfined",
// Not needed for now
// "--ulimit=core=-1:-1" // Allow core dumps
// NOTE: Not allowed in github CI devcontainers
//"--userns=keep-id:uid=1000,gid=1000",
// We pre-create this data-only container in initializeCommand
//"--volumes-from=starbash-test-data:ro"
],
// Download and initialize the test-data container
// "initializeCommand": "bash .devcontainer/create-test-data.sh",
"mounts": [
// NOTE: None of the following are allowed in GitHub CI devcontainers
// Needed for x11 forwarding, but throws: invalid mount config for type "bind": bind source path does not exist: /run/user/1000
// on github CI.
//"source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached",
//"source=/run/user/1000,target=/run/user/1000,type=bind",
// This isn't needed - much better to just pass in the XAUTHORITY env var (because this filename keeps changing)
// Mount the X11 authority file to allow GUI apps in the container to connect to the host's display
//"source=${localEnv:XAUTHORITY},target=${localEnv:XAUTHORITY},type=bind",
//{
// was ${env:XAUTHORITY} but that file keeps changing, so just mount a temp file and have fix-xauth.sh update it
// "source": "${localEnv:HOME}/myxauth.lnk",
// "target": "/tmp/.docker.xauth",
// "type": "bind"
//},
// vscode auto export of git config into my container sometimes seems busted (I'm not sure why this is only needed sometimes)
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.gitconfig,target=/home/vscode/.gitconfig,type=bind,consistency=cached",
// let container see host dbus, so that flatpak can work inside
//"source=/run/dbus,target=/run/dbus,type=bind",
// It is handy to have some test images available in the container
//"source=${localEnv:HOME}/Pictures/telescope,target=/workspaces/starbash/images,type=bind,consistency=cached",
//"source=/mnt/kshared,target=/mnt/kshared,type=bind,consistency=cached",
// This is necessary to prevent newer vscode created images from being able to write to /tmp
"type=tmpfs,destination=/tmp,tmpfs-mode=1777"
// My external USB drive
//"source=/mnt/fast_stick,destination=/mnt/fast_stick,type=bind"
],
"containerEnv": {
// Needed for X11 forwarding
//"DISPLAY": "${localEnv:DISPLAY}",
//"XAUTHORITY": "/tmp/.docker.xauth",
"PYTHONDEVMODE": "1", // Enable Python dev mode for better debug output
// "PYTHONPYCACHEPREFIX": "/workspaces/starbash/.pycache",
"SENTRY_ENVIRONMENT": "development", // For sentry.io reporting
// Allows 'docker' commands to work inside the container via the host's podman
"DOCKER_HOST": "unix:///run/user/1000/podman/podman.sock",
// Allow container runtime to now what the sub directory under /workspaces is
"PROJECT_NAME": "${localWorkspaceFolderBasename}",
"DEVCONTAINER_DIR": "/workspaces/${localWorkspaceFolderBasename}/.devcontainer/."
},
"remoteUser": "vscode",
"postCreateCommand": "bash .devcontainer/./post-create.sh",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
//"ms-python.python",
//"charliermarsh.ruff",
//"tamasfe.even-better-toml",
//"github.copilot",
//"skellock.just",
//"detachhead.basedpyright",
//"bierner.markdown-mermaid"
// "google.geminicodeassist"
],
"settings": {
//"terminal.integrated.defaultProfile.linux": "zsh"
}
}
}
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
30 changes: 30 additions & 0 deletions .devcontainer/on-shell-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# --- Add any commands you want to run for each new shell ---

# Set Ptyxis terminal tab title (if under that terminal)
if [[ -n "$PTYXIS_VERSION" ]]; then
# For zsh, disable auto-title and use precmd hook to persist the title
if [[ -n "$ZSH_VERSION" ]]; then
DISABLE_AUTO_TITLE="true"
precmd() { printf '\033]0;%s\007' "geeksville-dev"; }
else
# For bash, just set it once
printf '\033]0;%s\007' "geeksville-dev"
fi
fi

echo "🚀 Geeksville dev shell started!"

cd /workspaces/$PROJECT_NAME

# To find siril and other flatpaks
export PATH="$PATH:$HOME/.local/share/flatpak/exports/bin/"

# to reach our sb command
export PATH="$PWD/.venv/bin:$PATH"

# Limit OpenBLAS threads to prevent resource warnings when running tests
# GraXpert's numpy/scipy dependencies use OpenBLAS which tries to create too many threads
export OPENBLAS_NUM_THREADS=4

33 changes: 33 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -e

echo "source $DEVCONTAINER_DIR/on-shell-start.sh" >> ~/.bashrc
echo "source $DEVCONTAINER_DIR/on-shell-start.sh" >> ~/.zshrc

# Enable VS Code shell integration
echo '[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path bash)"' >> ~/.bashrc
echo '[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path zsh)"' >> ~/.zshrc

# Fix git credential helper to use container's gh path instead of host's homebrew path (we might not be allowed to write to ~/.gitconfig though)
if command -v git &> /dev/null; then
git config --global --unset-all credential.'https://github.com'.helper 2>/dev/null || true
git config --global --add credential.'https://github.com'.helper '!/usr/bin/gh auth git-credential' || true
git config --global --unset-all credential.'https://gist.github.com'.helper 2>/dev/null || true
git config --global --add credential.'https://gist.github.com'.helper '!/usr/bin/gh auth git-credential' || true
fi

# for zsh completions: Add to fpath and enable completions if not already present
if ! grep -q "fpath+=~/.zfunc" ~/.zshrc; then
echo 'fpath+=~/.zfunc' >> ~/.zshrc
echo 'autoload -Uz compinit && compinit' >> ~/.zshrc
fi

echo "Ensuring we have the submodules..."
git submodule update --init --recursive

echo "Trying to limit SCAD ram usage..."
mkdir -p ~/.config/OpenSCAD
cp $DEVCONTAINER_DIR/OpenSCAD.conf ~/.config/OpenSCAD

#echo "Doing an initial build..."
#make