Instantly share code, notes, and snippets.

What would you like to do?
Dockerfiles for dev images
export TERM="xterm-256color"
export CLICOLOR="true"
alias ls="ls --color"
alias ll="ls --color -alh"
get-git-dirty-state() {
if [[ $(git status 2> /dev/null | tail -n1) =~ "nothing to commit" ]]; then
echo ""
echo "*"
get-git-branch() {
branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
if [ ! -z "$branch" ]; then
echo " [$branch]"
#export PS1="$LIGHT_GREEN[\D{%H:%M:%S}]$WHITE ${debian_chroot:+($debian_chroot)}\w »$WHITE "
export PS1="$LIGHT_GREEN{SANDBOX} [\D{%H:%M:%S}]$WHITE ${debian_chroot:+($debian_chroot)}\w$MAGENTA\$(get-git-branch)$RED >$WHITE "
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
# append to the history file, don't overwrite it
shopt -s histappend
export HISTCONTROL=ignoredups:erasedups # no duplicate entries
export HISTSIZE=100000 # big big history
export HISTFILESIZE=100000 # big big history
# Save and reload the history after each command finishes
# export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# Helper function for sending commands to other tmux panes
function tsk {
tmux send-keys -t right "$args" C-m
FROM ndpi/emacs-base
USER root
RUN apt-get update && apt-get install -y \
tmux \
sudo \
&& rm -rf /var/lib/apt/lists/*
COPY sudoers /etc/sudoers.d/90-nick-dev-image
RUN chmod 0440 /etc/sudoers.d/90-nick-dev-image
USER nick
COPY gray.tmuxtheme /home/nick/gray.tmuxtheme
COPY tmux.conf /home/nick/.tmux.conf
COPY bashrc /home/nick/.bashrc
COPY /home/nick/
ENTRYPOINT /bin/bash /home/nick/
#! /bin/bash
# Set up a tmux session with a default layout.
tmux start-server
tmux new-session -d -s "$SESSION"
# Set up the main window with Emacs.
tmux selectp -t 0
tmux send-keys "emacs" C-m
# Split the window horizontally, and start any worker processes specified by the sandbox.
tmux splitw -h -p 35
if [ -e "/home/nick/" ]; then
tmux send-keys "/home/nick/" C-m
# If no helper script defined, list the /src directory.
tmux send-keys "ls -al" C-m
# Split the window again, vertically this time.
tmux selectp -t 1
tmux splitw -v -p 75
# Show git status in 3rd window.
tmux selectp -t 2
tmux send-keys "git status" C-m
# Switch back to Emacs.
tmux selectp -t 0
# Attach to the session we created.
tmux attach-session -t "$SESSION"
} &>/tmp/start-tmux.log
unbind-key C-b
set -g prefix 'C-\'
bind-key 'C-\' send-prefix
set-option -g default-shell "/bin/bash"
source-file "$HOME/gray.tmuxtheme"
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y \
emacs-nox \
python \
curl \
git \
util-linux \
coreutils \
findutils \
grep \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -m -u 501 -U nick
COPY . /home/nick/.emacs.d/
RUN chown -R nick:nick /home/nick
RUN mv /home/nick/.emacs.d/path.docker.txt /home/nick/.path.txt
RUN mkdir /src; chown -R nick:nick /src
USER nick
WORKDIR /home/nick/.emacs.d/
RUN curl -fsSL | python && \
/home/nick/.cask/bin/cask install && \
/home/nick/.cask/bin/cask list
ENTRYPOINT emacs -nw
FROM ndpi/dev-base
USER root
RUN apt-get update && apt-get install -y \
nodejs \
npm \
ocaml \
&& rm -rf /var/lib/apt/lists/*
# Note: bs-platform install will fail if npm is >= 5.0.0, so install it first
# then update npm.
RUN npm install -g bs-platform reason-cli
RUN npm install -g npm@latest
USER nick
COPY /home/nick/
# Install an Emacs module which sets up ReasonML integration.
COPY /home/nick/.emacs.d/modules

Emacs configuration module for ReasonML development

(package-install 'reason-mode)
(package-install 'tuareg)
(package-install 'merlin-eldoc)

(setq refmt-width-mode 'fill)
(setq merlin-command "ocamlmerlin")
(setq merlin-eldoc-occurrences nil)

(add-hook 'reason-mode-hook
          (lambda ()
            (add-hook 'before-save-hook 'refmt-before-save)))
(add-hook 'reason-mode-hook 'merlin-eldoc-setup)
#! /bin/bash
# Helper script for setting up the sandbox.
# Start an NPM build watcher process.
if [ -e "package.json" ]; then
npm start
echo "No package.json found here."
echo "Navigate to the project root and run 'npm start'."
#! /bin/bash
# This script helps with starting sandboxes based on the ndpi/dev-base image.
# Call it with the name of the docker image containing the dev sandbox and the
# directory to mount at /src.
docker run \
--mount type=bind,src=$2,dst=/src \
--mount type=bind,src=$HOME/.ssh,dst=/home/nick/.ssh,readonly \
-p 8080:8080 \
-p 3000:3000 \
-e TERM -e COLUMNS="`tput cols`" -e LINES="`tput lines`" \
-e TZ='America/New_York'
-it $1
# Give 'nick' user passwordless sudo functionality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment