Add ocaml image and move all images to images/

This commit is contained in:
Stochastica 2021-02-21 13:07:00 -05:00
parent 5d2d7bc030
commit a93b289cba
17 changed files with 62 additions and 4 deletions

View File

@ -0,0 +1,23 @@
ARG OPAM_VERSION="4.10"
FROM ocaml/opam2:$OPAM_VERSION
ARG OPAM_VERSION
USER root
RUN apt-get update && apt-get install -y \
m4
ENV USER "opam"
USER $USER
ENV OPAM_SWITCH_PREFIX="/home/$USER/.opam/${OPAM_VERSION}"
ENV PATH="$OPAM_SWITCH_PREFIX/bin:$PATH"
ENV CAML_LD_LIBRARY_PATH="$OPAM_SWITCH_PREFIX/lib/stublibs:$OPAM_SWITCH_PREFIX/lib/ocaml/stublibs:$OPAM_SWITCH_PREFIX/lib/ocaml"
ENV OCAML_TOPLEVEL_PATH="$OPAM_SWITCH_PREFIX/lib/toplevel"
ENV MANPATH=":$OPAM_SWITCH_PREFIX/man"
# Build system
RUN opam update && opam upgrade && opam install \
cohttp \
landmarks \
merlin \
ocamlgraph \
ocamlformat
ENV TERM=xterm-256color

View File

@ -0,0 +1,6 @@
#!/bin/bash
script=$(basename $0)
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
$DIR/run-in-docker "$script" ${@} <&0

View File

@ -0,0 +1,27 @@
#!/bin/bash
set -euo pipefail
DOCKER_NAME="ocaml-merlin"
OCAML_BIN_OUT="~/common/images/ocaml-merlin"
# Transforms directories to internal directories for ocaml
function transform_stdin {
sed -e "s!$DIR!/data!g"
}
function transform_stdout {
sed -e "s!/data!$DIR!g" | sed -e "s!/home/opam/.opam/.*/bin!$OCAML_BIN_OUT!g"
}
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
ARGS=${@}
ARGS=$(echo ${ARGS} | transform_stdin)
if [ -t 0 ] ;
then
docker exec -it $NAME ${ARGS} ;
else
# Replace any in-container filenames with host filesnames (stdout + stderr)
{ cat <&0 | transform_stdin | docker exec -i $NAME ${ARGS} 2>&1 1>&3 3>&- | transform_stdout; } 3>&1 1>&2 | transform_stdout
fi

View File

@ -0,0 +1 @@
./ocaml-exec.sh

1
images/ocaml-merlin/opam Symbolic link
View File

@ -0,0 +1 @@
./ocaml-exec.sh

View File

@ -1,11 +1,11 @@
#!/bin/bash
# Calculate directory relative to $HOME
COMMON_BIN=$PWD/bin
IMAGES=$PWD/images/latex/bin
LOCAL_BIN=/usr/local/bin
pushd $LOCAL_BIN >> /dev/null
ln -vs $COMMON_BIN/latex-runtime.sh .
ln -vs $COMMON_BIN/latexmk .
ln -vs $COMMON_BIN/pdflatex .
ln -vs $IMAGES/latex/bin/latex-runtime.sh .
ln -vs $IMAGES/latex/bin/latexmk .
ln -vs $IMAGES/latex/bin/pdflatex .
popd >> /dev/null