Skip to content
This repository has been archived by the owner on Dec 8, 2019. It is now read-only.

Commit

Permalink
Merge pull request #15 from leighmcculloch/tags-for-each-unison-and-o…
Browse files Browse the repository at this point in the history
…caml-version

Tags for each unison and ocaml version
  • Loading branch information
leighmcculloch authored Jul 16, 2016
2 parents d8a09a9 + 3046fb8 commit aff959f
Show file tree
Hide file tree
Showing 17 changed files with 215 additions and 43 deletions.
25 changes: 9 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,28 @@ CMD ["/sbin/my_init"]
MAINTAINER Leigh McCulloch

# Upload Unison for building
COPY unison-2.40.102.tar.gz /tmp/unison/
COPY unison-2.48.3.tar.gz /tmp/unison/
COPY container /

# Allow setting these on build
ARG UNISON_VERSION=${UNISON_VERSION}
ARG OCAML_VERSION=${OCAML_VERSION}

# Build and install Unison versions then cleanup
COPY unison-install.sh .
RUN apt-get update -y \
&& apt-get install -y wget \
&& wget http://download.opensuse.org/repositories/home:ocaml/xUbuntu_14.04/Release.key \
&& curl -LO http://download.opensuse.org/repositories/home:ocaml/xUbuntu_14.04/Release.key \
&& apt-key add - < Release.key \
&& sh -c "echo 'deb http://download.opensuse.org/repositories/home:/ocaml/xUbuntu_14.04/ /' >> /etc/apt/sources.list.d/ocaml.list" \
&& apt-get update -y \
&& apt-get install -y ocaml build-essential exuberant-ctags \
&& ./unison-install.sh \
&& apt-get purge -y ocaml build-essential exuberant-ctags \
&& apt-get clean autoclean \
&& apt-get autoremove -y \
&& dependencies-install.sh \
&& unison-install.sh \
&& dependencies-purge.sh \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ /tmp/* /var/tmp/*

# Set default Unison configuration
ENV UNISON_VERSION=2.48.3
ENV UNISON_WORKING_DIR=/unison

COPY unison-link.sh .
RUN ./unison-link.sh

# Set working directory to be the home directory
WORKDIR /root

# Setup unison to run as a service
VOLUME $UNISON_WORKING_DIR
COPY unison-run.sh /etc/service/unison/run
EXPOSE 5000
31 changes: 31 additions & 0 deletions Dockerfile-unison2.40.102-ocaml4.01
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM phusion/baseimage:0.9.16
CMD ["/sbin/my_init"]

MAINTAINER Leigh McCulloch

# Upload Unison for building
COPY container /

# Allow setting these on build
ARG UNISON_VERSION=2.40.102
ARG OCAML_VERSION=4.01

# Build and install Unison versions then cleanup
RUN apt-get update -y \
&& curl -LO http://download.opensuse.org/repositories/home:ocaml/xUbuntu_14.04/Release.key \
&& apt-key add - < Release.key \
&& apt-get update -y \
&& dependencies-install.sh \
&& unison-install.sh \
&& dependencies-purge.sh \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ /tmp/* /var/tmp/*

# Set default Unison configuration
ENV UNISON_WORKING_DIR=/unison

# Set working directory to be the home directory
WORKDIR /root

# Setup unison to run as a service
VOLUME $UNISON_WORKING_DIR
EXPOSE 5000
31 changes: 31 additions & 0 deletions Dockerfile-unison2.40.102-ocaml4.02
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM phusion/baseimage:0.9.16
CMD ["/sbin/my_init"]

MAINTAINER Leigh McCulloch

# Upload Unison for building
COPY container /

# Allow setting these on build
ARG UNISON_VERSION=2.40.102
ARG OCAML_VERSION=4.02

# Build and install Unison versions then cleanup
RUN apt-get update -y \
&& curl -LO http://download.opensuse.org/repositories/home:ocaml/xUbuntu_14.04/Release.key \
&& apt-key add - < Release.key \
&& apt-get update -y \
&& dependencies-install.sh \
&& unison-install.sh \
&& dependencies-purge.sh \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ /tmp/* /var/tmp/*

# Set default Unison configuration
ENV UNISON_WORKING_DIR=/unison

# Set working directory to be the home directory
WORKDIR /root

# Setup unison to run as a service
VOLUME $UNISON_WORKING_DIR
EXPOSE 5000
31 changes: 31 additions & 0 deletions Dockerfile-unison2.48.3-ocaml4.01
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM phusion/baseimage:0.9.16
CMD ["/sbin/my_init"]

MAINTAINER Leigh McCulloch

# Upload Unison for building
COPY container /

# Allow setting these on build
ARG UNISON_VERSION=2.48.3
ARG OCAML_VERSION=4.01

# Build and install Unison versions then cleanup
RUN apt-get update -y \
&& curl -LO http://download.opensuse.org/repositories/home:ocaml/xUbuntu_14.04/Release.key \
&& apt-key add - < Release.key \
&& apt-get update -y \
&& dependencies-install.sh \
&& unison-install.sh \
&& dependencies-purge.sh \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ /tmp/* /var/tmp/*

# Set default Unison configuration
ENV UNISON_WORKING_DIR=/unison

# Set working directory to be the home directory
WORKDIR /root

# Setup unison to run as a service
VOLUME $UNISON_WORKING_DIR
EXPOSE 5000
31 changes: 31 additions & 0 deletions Dockerfile-unison2.48.3-ocaml4.02
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM phusion/baseimage:0.9.16
CMD ["/sbin/my_init"]

MAINTAINER Leigh McCulloch

# Upload Unison for building
COPY container /

# Allow setting these on build
ARG UNISON_VERSION=2.48.3
ARG OCAML_VERSION=4.02

# Build and install Unison versions then cleanup
RUN apt-get update -y \
&& curl -LO http://download.opensuse.org/repositories/home:ocaml/xUbuntu_14.04/Release.key \
&& apt-key add - < Release.key \
&& apt-get update -y \
&& dependencies-install.sh \
&& unison-install.sh \
&& dependencies-purge.sh \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ /tmp/* /var/tmp/*

# Set default Unison configuration
ENV UNISON_WORKING_DIR=/unison

# Set working directory to be the home directory
WORKDIR /root

# Setup unison to run as a service
VOLUME $UNISON_WORKING_DIR
EXPOSE 5000
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build:
sed -e "s/\$${UNISON_VERSION}/2.48.3/" -e "s/\$${OCAML_VERSION}/4.02/" Dockerfile > Dockerfile-unison2.48.3-ocaml4.02
sed -e "s/\$${UNISON_VERSION}/2.48.3/" -e "s/\$${OCAML_VERSION}/4.01/" Dockerfile > Dockerfile-unison2.48.3-ocaml4.01
sed -e "s/\$${UNISON_VERSION}/2.40.102/" -e "s/\$${OCAML_VERSION}/4.02/" Dockerfile > Dockerfile-unison2.40.102-ocaml4.02
sed -e "s/\$${UNISON_VERSION}/2.40.102/" -e "s/\$${OCAML_VERSION}/4.01/" Dockerfile > Dockerfile-unison2.40.102-ocaml4.01
34 changes: 28 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The docker image is available on Docker Hub:
First, you can launch a volume container exposing a volume with Unison.

```bash
$ CID=$(docker run -d -p 5000:5000 -e UNISON_VERSION=2.48.3 -e UNISON_WORKING_DIR=/unison leighmcculloch/unison)
$ CID=$(docker run -d -p 5000:5000 -e UNISON_WORKING_DIR=/unison leighmcculloch/unison:latest)
```

You can then sync a local folder to `/unison` in the container with:
Expand All @@ -38,9 +38,8 @@ mywebserver:
volumes_from:
- unison
unison:
image: leighmcculloch/unison
image: leighmcculloch/unison:latest
environment:
- UNISON_VERSION=2.48.3
- UNISON_WORKING_DIR=/unison
ports:
- "5000:5000"
Expand All @@ -59,13 +58,36 @@ $ fswatch -o . | xargs -n1 -I{} unison . socket://<docker>:5000/ -ignore 'Path .
```

## Installing Unison Locally
Unison requires the version of the client (running on the host) and server (running in the container) to match. This docker image includes common versions of Unison server which can be selected with the `UNISON_VERSION` environment variable.
Unison requires the version of the client (running on the host) and server (running in the container) to match.

* 2.40.102 (available via `apt-get install unison` on Ubuntu 14.04, 14.10, 15.04)
* 2.48.3 (available via `brew install unison` on Mac OS X) [default]
* 2.40.102 (available via `apt-get install unison` on Ubuntu 14.04, 14.10, 15.04) [compiled with ocaml 4.01]
* 2.48.3 (available via `brew install unison` on Mac OS X) [compiled with ocaml 4.02]

## Available Unison Images
This docker repository includes common versions of Unison server compiled with different versions of OCaml. The version you need can be selected by choosing the appropriately tagged image from the docker hub repository. Images are tagged in the format:

```
VERSION-[unisonUNISON_VERSION[-OCAML_VERSION]]
```

Supported versions are any combination of the following:

* Unison 2.40.102 and 2.48.3
* OCaml 4.01 and 4.02

Additional versions can be added easily on request. Open an Issue if you need another version.

### Examples
| Docker Image Tag | Unison | OCaml |
| ------------------------------------------------------- | ---------- | ------- |
| `leighmcculloch/unison:latest` | `2.48.3` | `4.02` |
| `leighmcculloch/unison:latest-unison2.48.3` | `2.48.3` | `4.02` |
| `leighmcculloch/unison:latest-unison2.48.3-ocaml4.02` | `2.48.3` | `4.02` |
| `leighmcculloch/unison:latest-unison2.48.3-ocaml4.01` | `2.48.3` | `4.01` |
| `leighmcculloch/unison:latest-unison2.40.102` | `2.40.102` | `4.02` |
| `leighmcculloch/unison:latest-unison2.40.102-ocaml4.02` | `2.40.102` | `4.02` |
| `leighmcculloch/unison:latest-unison2.40.102-ocaml4.01` | `2.40.102` | `4.01` |

## Installing fswatch Locally
Get fswatch using `brew install fswatch` on Mac OS X otherwise [download and compile from a release build](http://emcrisostomo.github.io/fswatch/).

Expand Down
1 change: 1 addition & 0 deletions container/etc/apt/sources.list.d/ocaml.list
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deb http://download.opensuse.org/repositories/home:/ocaml/xUbuntu_14.04/ /
4 changes: 4 additions & 0 deletions container/etc/service/unison/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
export HOME=/root
cd $UNISON_WORKING_DIR
exec unison -socket 5000 >>/var/log/unison.log 2>&1
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions container/usr/local/bin/dependencies-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

case "${OCAML_VERSION}" in
'4.02' | 'latest')
apt-get install -y ocaml
;;
*)
apt-get install -y\
ocaml=${OCAML_VERSION}.*\
camlp4=${OCAML_VERSION}.*\
ocaml-nox=${OCAML_VERSION}.*\
ocaml-base=${OCAML_VERSION}.*\
ocaml-interp=${OCAML_VERSION}.*\
ocaml-base-nox=${OCAML_VERSION}.*\
ocaml-compiler-libs=${OCAML_VERSION}.*\
;;
esac

apt-get install -y build-essential exuberant-ctags
14 changes: 14 additions & 0 deletions container/usr/local/bin/dependencies-purge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

apt-get purge -y \
ocaml \
ocaml-nox \
ocaml-base \
ocaml-interp \
ocaml-base-nox \
ocaml-compiler-libs \
camlp4 \
build-essential \
exuberant-ctags \
&& apt-get clean autoclean \
&& apt-get autoremove -y
11 changes: 11 additions & 0 deletions container/usr/local/bin/unison-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

UNISON_RELEASE=unison-${UNISON_VERSION}
cd /tmp/unison
tar -zxvf ${UNISON_RELEASE}.tar.gz
cd ${UNISON_RELEASE}
make UISTYLE=text
cp unison /bin/
if [ -f 'unison-fsmonitor' ]; then
cp unison-fsmonitor /bin/
fi
14 changes: 0 additions & 14 deletions unison-install.sh

This file was deleted.

3 changes: 0 additions & 3 deletions unison-link.sh

This file was deleted.

4 changes: 0 additions & 4 deletions unison-run.sh

This file was deleted.

0 comments on commit aff959f

Please # to comment.