branch: elpa/cider
commit 9e4bce60d946f6f677ae515b65a6734af26280cc
Author: vemv <v...@users.noreply.github.com>
Commit: vemv <v...@users.noreply.github.com>

    Add a Dockerfile for TRAMP development purposes
---
 dev/sample-project/Dockerfile  | 61 ++++++++++++++++++++++++++++++++++++++++++
 dev/sample-project/Makefile    | 10 +++++++
 dev/sample-project/README.md   | 17 ++++++++++++
 dev/sample-project/project.clj |  5 ++++
 dev/sample-project/src/foo.clj |  3 +++
 5 files changed, 96 insertions(+)

diff --git a/dev/sample-project/Dockerfile b/dev/sample-project/Dockerfile
new file mode 100644
index 0000000000..01890c1c70
--- /dev/null
+++ b/dev/sample-project/Dockerfile
@@ -0,0 +1,61 @@
+# Use an official Clojure runtime as a parent image
+FROM clojure:temurin-17-lein-bullseye
+
+# Set environment variables to non-interactive (this prevents some prompts)
+ENV DEBIAN_FRONTEND=noninteractive
+
+# Define environment variable for nREPL port
+ENV NREPL_PORT=7888
+
+RUN apt-get update \
+    && apt-get install -y openssh-server locales \
+    && mkdir /var/run/sshd
+
+RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
+    locale-gen
+ENV LANG en_US.UTF-8
+ENV LANGUAGE en_US:en
+ENV LC_ALL en_US.UTF-8
+
+RUN locale-gen en_US.UTF-8
+RUN locale-gen en en_US en_US.UTF-8
+RUN dpkg-reconfigure locales
+
+# Set root password
+RUN echo 'root:cider' | chpasswd
+
+RUN sed -i 's/^#* *PasswordAuthentication .*/PasswordAuthentication yes/' 
/etc/ssh/sshd_config
+RUN sed -i 's/^#* *PermitRootLogin .*/PermitRootLogin yes/' 
/etc/ssh/sshd_config
+RUN sed -i 's/^#* *ChallengeResponseAuthentication 
.*/ChallengeResponseAuthentication yes/' /etc/ssh/sshd_config
+
+# SSH login fix. Otherwise user is kicked off after login
+RUN sed 's@session\s*required\s*pam_loginuid.so@session optional 
pam_loginuid.so@g' -i /etc/pam.d/sshd
+
+# Expose SSH port
+EXPOSE 22
+
+CMD ["/usr/sbin/sshd", "-D"]
+
+# Set the working directory in the docker image
+WORKDIR /usr/src/app
+
+# Copy the current directory contents into the directory at /usr/src/app in 
the image
+COPY . /usr/src/app
+
+# Install any needed packages specified in project.clj
+RUN lein deps
+
+# Forward all relevant env vars for ssh sessions
+RUN echo "export JAVA_HOME=${JAVA_HOME}" >> /root/.bashrc
+RUN echo "export LEIN_HOME=${LEIN_HOME}" >> /root/.bashrc
+RUN echo "export LEIN_JAVA_CMD=${LEIN_JAVA_CMD}" >> /root/.bashrc
+RUN echo "export LEIN_JVM_OPTS=${LEIN_JVM_OPTS}" >> /root/.bashrc
+RUN echo "export LEIN_ROOT=${LEIN_ROOT}" >> /root/.bashrc
+RUN echo "export NREPL_PORT=${NREPL_PORT}" >> /root/.bashrc
+RUN echo "export PATH=${PATH}" >> /root/.bashrc
+
+# Make port 7888 available to the world outside this container (nREPL default 
port)
+#EXPOSE 7888
+
+# Run lein repl when the container launches, on port defined by NREPL_PORT
+#CMD ["lein", "repl", ":headless", ":host", "0.0.0.0", ":port", "7888"]
diff --git a/dev/sample-project/Makefile b/dev/sample-project/Makefile
new file mode 100644
index 0000000000..d2487db65e
--- /dev/null
+++ b/dev/sample-project/Makefile
@@ -0,0 +1,10 @@
+build:
+       DOCKER_BUILDKIT=0 docker build --no-cache -t cider-tramp-dev .
+
+run: build
+       docker run -p 7888:7888 -p 8022:22 cider-tramp-dev
+
+ssh:
+       ssh-keygen -R "[localhost]:8022"
+       echo "Password is: cider"
+       ssh root@localhost -p 8022
diff --git a/dev/sample-project/README.md b/dev/sample-project/README.md
new file mode 100644
index 0000000000..c731ed072d
--- /dev/null
+++ b/dev/sample-project/README.md
@@ -0,0 +1,17 @@
+This project spins up a Clojure project within a Docker image.
+
+The Docker image exposes a SSH server.
+
+This way, for development purposes, we can SSH into it with TRAMP and exercise 
CIDER's TRAMP-related capabilities.
+
+To get started:
+
+* In one terminal tab, run `make run` to run the Docker image
+* Once it's ready, from another tab, run `make ssh` 
+  * The password is `cider`
+  * `cd /usr/src/app; lein repl :headless :host 0.0.0.0 :port 7888`
+
+Now, from emacs you can `cider-connect` to localhost.
+
+* `M-:`, `(dired "/sshx:root@localhost#8022:/usr/src/app")`
+* `M-x cider-connect` (choose `localhost`, `7888`)
diff --git a/dev/sample-project/project.clj b/dev/sample-project/project.clj
new file mode 100644
index 0000000000..a57ba3a938
--- /dev/null
+++ b/dev/sample-project/project.clj
@@ -0,0 +1,5 @@
+(defproject cider-tramp-dev "0"
+  :dependencies [[org.clojure/clojure "1.11.1"]
+                 [clj-http "3.12.3"]]
+  :source-paths ["src"]
+  :plugins [[cider/cider-nrepl "0.35.0"]])
diff --git a/dev/sample-project/src/foo.clj b/dev/sample-project/src/foo.clj
new file mode 100644
index 0000000000..e5a730e664
--- /dev/null
+++ b/dev/sample-project/src/foo.clj
@@ -0,0 +1,3 @@
+(ns foo
+  (:require
+   [clj-http.client :as client]))

Reply via email to