sn_node 0.34.8

Implementation of the nodes for the Safe Network.
Documentation
FROM rust:latest

ARG OPENSSL_VERSION=1.0.2r

RUN addgroup --gid 1001 maidsafe && \
    adduser --uid 1001 --ingroup maidsafe --home /home/maidsafe --shell /bin/sh --disabled-password --gecos "" maidsafe && \
    # The parent container sets this to the 'staff' group, which causes problems
    # with reading code stored in Cargo's registry.
    chgrp -R maidsafe /usr/local

# Install fixuid for dealing with permissions issues with mounted volumes.
# We could perhaps put this into a base container at a later stage.
RUN USER=maidsafe && \
    GROUP=maidsafe && \
    echo "06b3e053be5aaccc91dd5a45faf2356f  fixuid-0.4-linux-amd64.tar.gz" > fixuid-0.4-linux-amd64.tar.gz.md5 && \
    curl -OSsL https://github.com/boxboat/fixuid/releases/download/v0.4/fixuid-0.4-linux-amd64.tar.gz && \
    md5sum -c fixuid-0.4-linux-amd64.tar.gz.md5 && \
    tar -C /usr/local/bin -xzf fixuid-0.4-linux-amd64.tar.gz && \
    rm fixuid-0.4-linux-amd64.tar.gz && \
    chown root:root /usr/local/bin/fixuid && \
    chmod 4755 /usr/local/bin/fixuid && \
    mkdir -p /etc/fixuid && \
    printf "user: $USER\ngroup: $GROUP\n" > /etc/fixuid/config.yml

RUN apt-get update -y && \
    apt-get install -y \
        gcc \
        musl-dev \
        musl-tools && \
    mkdir -p /usr/local/musl/include && \
    ln -s /usr/include/linux /usr/local/musl/include/linux && \
    ln -s /usr/include/x86_64-linux-gnu/asm /usr/local/musl/include/asm && \
    ln -s /usr/include/asm-generic /usr/local/musl/include/asm-generic && \
    curl -LO "https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz" && \
    tar xvzf "openssl-$OPENSSL_VERSION.tar.gz" && \
    cd openssl-$OPENSSL_VERSION && \
    CC=musl-gcc ./Configure no-shared no-zlib -fPIC --prefix=/usr/local/musl -DOPENSSL_NO_SECURE_MEMORY linux-x86_64 && \
    CC=musl-gcc C_INCLUDE_PATH=/usr/local/musl/include/ make depend && \
    CC=musl-gcc C_INCLUDE_PATH=/usr/local/musl/include/ make && \
    CC=musl-gcc C_INCLUDE_PATH=/usr/local/musl/include/ make install && \
    mkdir /target && \
    chown maidsafe:maidsafe /target && \
    mkdir /usr/src/sn_node && \
    chown maidsafe:maidsafe /usr/src/sn_node && \
    apt-get clean -y && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/sn_node
COPY . .

# During the build process, ownership of the source directory needs changed in advance because
# the tests write a file and you need permissions for that.
RUN chown -R maidsafe:maidsafe /usr/src/sn_node
USER maidsafe:maidsafe
ENV CARGO_TARGET_DIR=/target \
    RUST_BACKTRACE=1
RUN rustup component add rustfmt clippy && \
    rustup target add x86_64-unknown-linux-musl
ENTRYPOINT ["fixuid"]