FROM resin/rpi-raspbian:jessie-20161026

RUN apt-get update && \
    apt-get install -y wget openjdk-8-jdk && \
    rm -rf /var/lib/apt/lists/*
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-armhf

ENV VER 3.1.0-04

RUN wget https://sonatype-download.global.ssl.fastly.net/nexus/3/nexus-${VER}-unix.tar.gz -O /tmp/nexus-${VER}-unix.tar.gz && \
        useradd -r -u 200 -m -c "nexus role account" -d /opt/sonatype-work -s /bin/false nexus && \
        mkdir -p /opt/sonatype/ && \
        mkdir -p /opt/sonatype-work && \
        tar -C /opt/sonatype/ -xvaf /tmp/nexus-${VER}-unix.tar.gz && \
        ln -s /opt/sonatype/nexus-${VER}/ /opt/sonatype/nexus && \
        rm -f /tmp/nexus-${VER}-unix.tar.gz && \
        chown -Rv nexus:nexus /opt/sonatype/nexus && \
        chown -Rv nexus:nexus /opt/sonatype/nexus-${VER} && \
        chown -Rv nexus:nexus /opt/sonatype-work

VOLUME /opt/sonatype-work

WORKDIR /opt/sonatype/nexus

COPY nexus.vmoptions /opt/sonatype/nexus/bin/nexus.vmoptions

USER nexus
CMD ["/opt/sonatype/nexus/bin/nexus", "run"]
