This is an automated email from the ASF dual-hosted git repository.

msciabarra pushed a commit to branch main
in repository 
https://gitbox.apache.org/repos/asf/openserverless-devcontainer.git

commit 8af2f6b4317dc83be840f5aace904f73c77069fb
Author: Michele Sciabarra <[email protected]>
AuthorDate: Sat Nov 22 19:44:41 2025 +0000

    devcontainer working with ssh and custom uid
---
 Dockerfile   | 42 +++++++++++++++++++-----------------------
 README.md    |  7 +++++++
 Taskfile.yml |  6 ++++++
 start-ssh.sh | 16 ----------------
 start.sh     | 32 ++++++++++++++++++++++++++++++++
 5 files changed, 64 insertions(+), 39 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index e2f213c..7f468fc 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,7 +4,7 @@ ENV DEBIAN_FRONTEND=noninteractive
 
 # Install build dependencies
 RUN apt-get update && apt-get install -y --no-install-recommends \
-    git curl sbcl make unzip ca-certificates \
+    git curl sbcl make unzip ca-certificates  \
     libsqlite3-dev libssl-dev gawk freetds-dev jq \
     && rm -rf /var/lib/apt/lists/*
 
@@ -21,36 +21,32 @@ RUN \
     wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc |  
apt-key add - && \
     apt update && \
     apt install -y less man-db sudo vim jq python-is-python3 
python3-virtualenv \
-    locales postgresql-client-16 openssh-server
+    locales postgresql-client-16 openssh-server tini supervisor
 
+# setup env
 RUN \
     touch /.dockerenv && \
     echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
     locale-gen en_US.UTF-8 && \
     update-locale ANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8
 
-# Ensure default `node` user has access to `sudo`
-ARG USERNAME=node
-RUN \
-    echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
-    && chmod 0440 /etc/sudoers.d/$USERNAME
-
-# install ops and plugins
-USER node
-RUN \
-    curl -sL 
https://raw.githubusercontent.com/apache/openserverless-cli/refs/heads/main/install.sh
 | bash
+# pgloader, uv, opencode, concurrently, ops
+COPY --from=pgloader-builder /build/pgloader/build/bin/pgloader 
/usr/bin/pgloader
 RUN \
     curl -LsSf https://astral.sh/uv/install.sh | sh
-
-ENV PATH="/home/node/.local/bin:${PATH}"
-
 RUN \
-    ops -update
+    npm install -g concurrently opencode-ai
 RUN \
-    git clone https://github.com/apache/openserverless-devcontainer 
/home/node/.ops/openserverless-devcontainer ;\
-    ln -sf  /home/node/.ops/devcontaine/olaris-tk /home/node/olaris-tk
-
-COPY --from=pgloader-builder /build/pgloader/build/bin/pgloader 
/usr/bin/pgloader
-ADD start-ssh.sh /start-ssh.sh
-
-CMD ["/start-ssh.sh"]
+    curl -sL 
https://raw.githubusercontent.com/apache/openserverless-cli/refs/heads/main/install.sh
 | bash \
+    && mv ~/.local/bin/ops /usr/local/bin/ops
+
+# remove node
+RUN userdel node ; rm -Rvf /home/node
+ENV HOME=/home
+ENV OPS_BRANCH=main
+ADD start.sh /start.sh
+
+ENTRYPOINT ["tini", "--"]
+CMD ["/start.sh"]
+RUN mkdir /workspace
+WORKDIR /workspace
diff --git a/README.md b/README.md
index a7c3d36..fb891dd 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,8 @@
 # DevContainer
+
+The devcontainer uses
+
+`/home` as home director
+`/workspace` as worspace folder
+
+you need to create an user doc
\ No newline at end of file
diff --git a/Taskfile.yml b/Taskfile.yml
index 3f8a448..7ee804a 100644
--- a/Taskfile.yml
+++ b/Taskfile.yml
@@ -8,6 +8,7 @@ vars:
     sh: git tag --sort=-creatordate | head -n 1 || "latest"
 
 tasks:
+  default: task --list-all
 
   show: "echo {{.NAME}}:{{.TAG}}"
 
@@ -18,6 +19,11 @@ tasks:
 
   build:
       - docker build -t "{{.NAME}}:{{.TAG}}" . --load
+      - task: show
+
+  clean:
+      - docker rm -f ssh-devcontainer || true
+      - docker images | awk '/<none>|devcontainer/{print $3}' | xargs docker 
rmi -f || true
 
   build-and-tag:
     - task: image-tag
diff --git a/start-ssh.sh b/start-ssh.sh
deleted file mode 100755
index 7461669..0000000
--- a/start-ssh.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-sudo mkdir -p /run/sshd
-sudo ssh-keygen -A
-mkdir -p ~/.ssh
-PORT=${SSH_PORT:-2222} d
-if test -n "$AUTHORIZED_KEY"
-then echo "$AUTHORIZED_KEY" >>~/.ssh/authorized_keys
-     chmod 600 ~/.ssh/authorized_keys
-fi
-if test -d /workspace
-then
-    ln -sf /workspace ~/workspace
-    sudo chown -R 1000:1000 /workspace
-fi
-echo Starting ssh in port $PORT
-sudo /usr/sbin/sshd -p $PORT -D
\ No newline at end of file
diff --git a/start.sh b/start.sh
new file mode 100755
index 0000000..0b5ed0b
--- /dev/null
+++ b/start.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+#setup sshd
+mkdir -p /run/sshd
+ssh-keygen -A
+
+export PORT1=${SSH_PORT:-2222}
+export PORT2=${OPENCODE_PORT:-2223}
+
+# setup user
+export HOME=/home
+if test -n "$USERID"
+then
+    useradd -u "$USERID" -d /home -o -U user -s /bin/bash
+    ops -update
+    git clone https://github.com/apache/openserverless-devcontainer 
$HOME/.ops/openserverless-devcontainer
+    ln -sf  $HOME/.ops/openserverless-devcontainer/olaris-tk 
$HOME/.ops/olaris-tk
+
+    if test -n "$SSHKEY"
+    then
+        mkdir -p $HOME/.ssh
+        echo "$SSHKEY" >>$HOME/.ssh/authorized_keys
+        chmod 600 ~/.ssh/authorized_keys
+    fi
+    chown -Rvf "$USERID" /home
+fi
+cd /workspace
+echo Starting ssh in port $PORT1 and opencode in $PORT2 for user $USERID
+concurrently \
+ "sudo /usr/sbin/sshd -p $PORT1 -D" \
+ "opencode serve -p $PORT2 --hostname 0.0.0.0"
+

Reply via email to