Page MenuHomeDevCentral

No OneTemporary

diff --git a/README.md b/README.md
index eedf35d..e8e4f42 100644
--- a/README.md
+++ b/README.md
@@ -1,40 +1,40 @@
# Nasqueron dev workspace
Install a development workspace as a container. The container contains
-a Go environment, ready to use.
+a comprehensive development 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
+$ (cd flavours/go && docker build -t nasqueron/dev-workspace-go .)
+$ support/workspace.sh go shell
```
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
+This workspace is intended for Go development, with Python, Git and Arcanist.
+
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/Dockerfile b/flavours/go/Dockerfile
similarity index 100%
rename from Dockerfile
rename to flavours/go/Dockerfile
diff --git a/files/root/.bashrc b/flavours/go/files/root/.bashrc
similarity index 100%
rename from files/root/.bashrc
rename to flavours/go/files/root/.bashrc
diff --git a/support/workspace.sh b/support/workspace.sh
index 448a1cc..c55ec8c 100755
--- a/support/workspace.sh
+++ b/support/workspace.sh
@@ -1,85 +1,99 @@
#!/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
+# Image: nasqueron/dev-workspace-<flavour>
# -------------------------------------------------------------
-BASE_IMAGE=nasqueron/dev-workspace-go
+set -e
+
+# -------------------------------------------------------------
+# Parse arguments
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+if [ $# -lt 2 ]; then
+ echo "Usage: $(basename "$0") <flavour> <command>" >&2
+ exit 1
+fi
+
+FLAVOUR=$1
+shift
+
+BASE_IMAGE=nasqueron/dev-workspace-$FLAVOUR
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/x-diff
Expires
Mon, Sep 15, 09:33 (16 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2983981
Default Alt Text
(4 KB)

Event Timeline