From 3b1de0eab59e250f024be9791ee7b098b2b025d9 Mon Sep 17 00:00:00 2001 From: Christopher Dove Date: Thu, 16 Jan 2025 01:45:36 +0000 Subject: [PATCH] Add dev container configuration (#23) * add devcontainer support files * update rbuild to look in /usr/bin/openscad-nightly for openscad-nightly --- .devcontainer/devcontainer.json | 19 +++++++++++++++++++ .devcontainer/dockerfile | 21 +++++++++++++++++++++ rbuild.py | 23 ++++++++++++++++++----- 3 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/dockerfile diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..6abf4f9 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,19 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/debian +{ + "build": { "dockerfile": "dockerfile" }, + "features": { + "ghcr.io/devcontainers/features/python:1": { + "installTools": true, + "version": "latest" + } + }, + + "customizations": { + }, + + "remoteUser": "vscode", + "mounts": [ + "source=rackstack-bashhistory,target=/commandhistory,type=volume" + ] +} \ No newline at end of file diff --git a/.devcontainer/dockerfile b/.devcontainer/dockerfile new file mode 100644 index 0000000..b101022 --- /dev/null +++ b/.devcontainer/dockerfile @@ -0,0 +1,21 @@ +FROM mcr.microsoft.com/devcontainers/base:bookworm + +RUN wget -qO- https://files.openscad.org/OBS-Repository-Key.pub | sudo tee /etc/apt/trusted.gpg.d/obs-openscad-nightly.asc \ + && echo "deb https://download.opensuse.org/repositories/home:/t-paul/Debian_12/ ./" >> /etc/apt/sources.list.d/openscad.list \ + && apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends openscad openscad-nightly libpng-dev libjpeg-dev libtiff-dev + + +RUN apt-get -y install --no-install-recommends imagemagick + +RUN curl -sL http://www.lcdf.org/gifsicle/gifsicle-1.91.tar.gz | tar -zx \ + && cd gifsicle-1.91 \ + && ./configure --disable-gifview \ + && make install + +ARG USERNAME=vscode +RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \ + && mkdir /commandhistory \ + && touch /commandhistory/.bash_history \ + && chown -R $USERNAME /commandhistory \ + && echo "$SNIPPET" >> "/home/$USERNAME/.bashrc" diff --git a/rbuild.py b/rbuild.py index 6e298e6..473d819 100644 --- a/rbuild.py +++ b/rbuild.py @@ -20,12 +20,25 @@ if os.name == "posix": else: # Assume Linux if not macOS print("Operating System: Linux") PATH_TO_OPENSCAD = '/usr/bin/openscad' - PATH_TO_OPENSCAD_NIGHTLY = '/snap/bin/openscad-nightly' + + if binary_exists(PATH_TO_OPENSCAD): + print(f"Binary found at {PATH_TO_OPENSCAD}") + else: + print(f"Binary not found at {PATH_TO_OPENSCAD}") - if binary_exists(PATH_TO_OPENSCAD): - print(f"Binary found at {PATH_TO_OPENSCAD}") - else: - print(f"Binary not found at {PATH_TO_OPENSCAD}") + POSSIBLE_PATH_LOCATIONS_FOR_OPENSCAD_NIGHTLY = [ + '/snap/bin/openscad-nightly', #Path when installed using the snap tooling + '/usr/bin/openscad-nightly' #Path when installed using apt (also used in dockerfile) + ] + + PATH_TO_OPENSCAD_NIGHTLY = '' + for LOCATION in POSSIBLE_PATH_LOCATIONS_FOR_OPENSCAD_NIGHTLY: + if binary_exists(LOCATION): + print(f"Nightly binary found at {LOCATION}") + PATH_TO_OPENSCAD_NIGHTLY = LOCATION + + if PATH_TO_OPENSCAD_NIGHTLY == '': + print('Nightly binary not installed') elif os.name == "nt": # Windows print("Operating System: Windows")