Page MenuHomeDevCentral

D2467.id6220.diff
No OneTemporary

D2467.id6220.diff

diff --git a/.arcconfig b/.arcconfig
new file mode 100644
--- /dev/null
+++ b/.arcconfig
@@ -0,0 +1,7 @@
+{
+ "repository.callsign": "DDEV",
+ "phabricator.uri": "https://devcentral.nasqueron.org",
+ "load": [
+ "shellcheck-linter"
+ ]
+}
diff --git a/.arclint b/.arclint
new file mode 100644
--- /dev/null
+++ b/.arclint
@@ -0,0 +1,27 @@
+{
+ "linters": {
+ "chmod": {
+ "type": "chmod"
+ },
+ "filename": {
+ "type": "filename"
+ },
+ "spelling": {
+ "type": "spelling"
+ },
+ "json": {
+ "type": "json",
+ "include": [
+ "(^\\.arcconfig$)",
+ "(^\\.arclint$)",
+ "(\\.json$)"
+ ]
+ },
+ "shell": {
+ "type": "shellcheck",
+ "include": [
+ "(\\.sh$)"
+ ]
+ }
+ }
+}
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,33 @@
+FROM debian:11
+
+ENV GO_VERSION 1.17.6
+
+RUN apt-get update && apt-get install -y \
+ git wget tmux nano procps links unzip curl \
+ python3 python3-venv python3-wheel \
+ php-cli php-curl php-xml \
+ shellcheck silversearcher-ag locales openssh-client clang-format \
+ rsync make libssl-dev gettext gcc \
+ --no-install-recommends && rm -r /var/lib/apt/lists/* && \
+ cd /tmp && \
+ wget https://go.dev/dl/go$GO_VERSION.linux-amd64.tar.gz && \
+ tar -C /usr/local -xzf go$GO_VERSION.linux-amd64.tar.gz && \
+ rm go$GO_VERSION.linux-amd64.tar.gz && \
+ curl -fsSL https://deb.nodesource.com/setup_current.x | bash - && \
+ apt-get install -y nodejs && \
+ cd /opt && \
+ git clone https://github.com/phacility/arcanist.git && \
+ git clone https://github.com/vhbit/clang-format-linter.git && \
+ git clone https://devcentral.nasqueron.org/source/shellcheck-linter.git && \
+ wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash && \
+ wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh && \
+ ln -s /opt/arcanist/bin/arc /usr/local/bin/arc && \
+ ln -s /opt/config/gitconfig /root/.gitconfig && \
+ ln -s /opt/config/arcrc /root/.arcrc
+
+COPY files /
+
+VOLUME ["/opt/config", "/opt/workspace"]
+WORKDIR /opt/workspace
+
+CMD bash
diff --git a/README.md b/README.md
new file mode 100644
--- /dev/null
+++ b/README.md
@@ -0,0 +1,40 @@
+# Nasqueron dev workspace
+
+Install a development workspace as a container. The container contains
+a Go environment, ready to use.
+
+## Built it, run it
+
+```
+$ git clone https://devcentral.nasqueron.org/source/docker-dev-workspace
+$ docker build -t nasqueron/dev-workspace-go .
+$ support/workspace.sh
+```
+
+The command `workspace` is a wrapper to run your container,
+with the current directory as your workspace. It drops privileges
+to the current user, building a specific image for your uid.
+
+## Configuration
+
+It uses the same volume than nasqueron/arcanist to share SSH, Git and
+Arcanist configuration, but is built from a fresh Debian image, and
+not from Nasqueron Arcanist or PHP image to be as neutral as possible.
+
+## Flavours
+
+Currently, we've a workspace intended for Go development, with Python
+Git Arcanist in support.
+
+It probably makes sense to create several flavours instead of trying
+to package everything in one image.
+
+### Go
+
+Download the release specified in the GO_VERSION environment variable
+at image build time, so we can provide an up-to-date Go version.
+
+It also provides a current version of Node.js, as required by Hound build
+process.
+
+When the container is run, GOPATH is configured to `<current folder>/go`.
diff --git a/files/root/.bashrc b/files/root/.bashrc
new file mode 100644
--- /dev/null
+++ b/files/root/.bashrc
@@ -0,0 +1,17 @@
+### This bash configuration file is static and provided by the image
+### As such, any edit is ephemeral and won't be available next session.
+
+# Autocompletion
+source /opt/git-completion.bash
+
+# Prompt - Git information
+source /opt/git-prompt.sh
+PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
+GIT_PS1_SHOWDIRTYSTATE=1
+GIT_PS1_SHOWUNTRACKEDFILES=1
+GIT_PS1_SHOWUPSTREAM="auto"
+GIT_PS1_SHOWCOLORHINTS=1
+
+# Go environment
+export PATH=$PATH:/usr/local/go/bin
+export GOPATH=/opt/workspace/go
diff --git a/support/workspace.sh b/support/workspace.sh
new file mode 100755
--- /dev/null
+++ b/support/workspace.sh
@@ -0,0 +1,85 @@
+#!/usr/bin/env bash
+
+# -------------------------------------------------------------
+# Nasqueron Dev Workspace
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Author: Sébastien Santoro aka Dereckson
+# Project: Nasqueron
+# Created: 2022-01-16
+# Description: Wrapper to launch a dev environment
+# as a Docker container
+# License: Trivial work, not eligible to copyright
+# If copyright eligible, BSD-2-Clause
+# Image: nasqueron/dev-workspace-go
+# -------------------------------------------------------------
+
+BASE_IMAGE=nasqueron/dev-workspace-go
+
+if [ -t 0 ]; then
+ # If a stdin entry is available
+ # launch the container in the
+ # interactive mode
+ FLAGS=-it
+fi
+
+UPDATE_MODE=0
+
+if [ "$1" = "shell" ]; then
+ # Launch commands in the container bash shell
+ COMMAND=bash
+elif [ "$1" = "update" ]; then
+ UPDATE_MODE=1
+else
+ COMMAND=$1
+fi
+shift
+
+# -------------------------------------------------------------
+# Build image
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+build_user_image () {
+ BUILD_DIR=$(mktemp -d -t dev-workspace-build-XXXXXXXXXX)
+ pushd "$BUILD_DIR" > /dev/null || exit 1
+ >&2 echo "🔨 Building user-specific image $IMAGE for $USER"
+ echo "FROM $BASE_IMAGE" > Dockerfile
+ echo "RUN groupadd -r $USER -g $GID && mkdir /home/$USER && useradd -u $UID -r -g $USER -d /home/$USER -s /bin/bash $USER && cp /root/.bashrc /home/$USER/ && chown -R $USER:$USER /home/$USER && ln -s /opt/config/gitconfig /home/$USER/.gitconfig && ln -s /opt/config/arcrc /home/$USER/.arcrc" >> Dockerfile
+ docker build -t "$IMAGE" .
+ popd > /dev/null
+ rm -rf "$BUILD_DIR"
+}
+
+test -v $UID && UID=$(id -u)
+test -v $GID && GID=$(id -g)
+
+if [ $UPDATE_MODE -eq 1 ]; then
+ docker pull $BASE_IMAGE
+
+ # Rebuild user image
+ IMAGE=$BASE_IMAGE:$UID-$GID
+ test $UID -eq 0 || build_user_image
+
+ exit
+fi
+
+if [ $UID -eq 0 ]; then
+ IMAGE=$BASE_IMAGE
+ CONTAINER_USER_HOME=/root
+else
+ IMAGE=$BASE_IMAGE:$UID-$GID
+ test ! -z $(docker images -q "$IMAGE") || build_user_image
+ CONTAINER_USER_HOME="/home/$USER"
+fi
+
+# -------------------------------------------------------------
+# Run container
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+# Recycle SSH configuration for arc container when it's available
+if [ -d ~/.arc/ssh ]; then
+ VOLUME_SSH="-v $HOME/.arc/ssh:$CONTAINER_USER_HOME/.ssh"
+else
+ VOLUME_SSH=""
+fi
+
+docker run $FLAGS --rm --user $UID:$GID -v ~/.arc:/opt/config -v "$PWD:/opt/workspace" $VOLUME_SSH $IMAGE $COMMAND "$@"

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 15:37 (21 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2249417
Default Alt Text
D2467.id6220.diff (6 KB)

Event Timeline