diff --git a/worker/.bashrc b/worker/.bashrc new file mode 100644 index 0000000..046886f --- /dev/null +++ b/worker/.bashrc @@ -0,0 +1,16 @@ +cat <<'MSG' + _____ _ _ _ + |_ _| | | (_) | + | | _ __ | |_ ___ __ _ _ __ _| |_ ___ ___ + | | | '_ \| __/ _ \/ _` | '__| | __/ _ \/ _ \ + _| |_| | | | || __/ (_| | | | | || __/ __/ + |_____|_| |_|\__\___|\__, |_| |_|\__\___|\___| + __/ | + |___/ + +::::::::::::::::: Thanks for using Integritee's devevelpment environment! ::::::::::::::::: + +Please be sure you are following the documentation: +https://docs.integritee.network/5-nodes-and-infrastructure/5.2-how-to-set-up-and-run-a-sidechain-or-tocw-node/5.2.3-software-requirements/5.2.3.2-docker + +MSG \ No newline at end of file diff --git a/worker/Dockerfile b/worker/Dockerfile index b00b54b..42c57a4 100644 --- a/worker/Dockerfile +++ b/worker/Dockerfile @@ -112,13 +112,6 @@ RUN mkdir -p /ipfs && \ cd go-ipfs && \ ./install.sh -# Install Rust -RUN apt-get update && apt-get install -y curl -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y - -RUN /root/.cargo/bin/rustup component add rust-src clippy rust-analysis rustfmt -RUN /root/.cargo/bin/rustup self update - # re-install / downgrade binutils since the baiduxlab/sgx-rust image # comes with ld version 2.35 which cannot compile the node. RUN apt-get remove -y binutils && \ @@ -170,13 +163,41 @@ RUN apt-get update && apt-get install -y \ # install netcat for healthcheck RUN apt-get update && apt-get install -yq \ netcat \ + curl \ + gosu \ && rm -rf /var/lib/apt/lists/* && \ rm -rf /var/cache/apt/archives/* + +# +# Adding default user ubuntu +# The user id could be changed during start, see entrypoint.sh +# +ARG UID=1000 +ARG GUID=1000 +RUN adduser -u ${UID} --disabled-password --gecos '' ubuntu +RUN adduser -u ${UID} ubuntu sudo +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +# +# Install Rust +# +ENV RUSTUP_HOME=/opt/rust +ENV CARGO_HOME=/opt/rust +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path +RUN chmod 777 /opt/rust -R + # set environment variables ENV DEBIAN_FRONTEND noninteractive ENV TERM xterm ENV SGX_SDK /opt/sgxsdk -ENV PATH "$PATH:${SGX_SDK}/bin:${SGX_SDK}/bin/x64:/root/.cargo/bin" +ENV PATH "$PATH:${SGX_SDK}/bin:${SGX_SDK}/bin/x64:/opt/rust/bin" ENV PKG_CONFIG_PATH "${PKG_CONFIG_PATH}:${SGX_SDK}/pkgconfig" ENV LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:${SGX_SDK}/sdk_libs" + +COPY entrypoint.sh /entrypoint.sh +COPY .bashrc /home/ubuntu/ + +WORKDIR /home/ubuntu + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/worker/entrypoint.sh b/worker/entrypoint.sh new file mode 100755 index 0000000..05272cd --- /dev/null +++ b/worker/entrypoint.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +MYUID="${MYUID:-1000}" +MYGUID="${MYGUID:-1000}" +#echo ${MYUID} + +u=`id -u ubuntu` +if [ $u != $MYUID ] +then + echo "Setting up permissions, please wait..." + usermod -u ${MYUID} ubuntu + groupmod -g ${MYGUID} ubuntu + chown -R ubuntu.ubuntu /home/ubuntu +fi +#echo $MYUID +#chown -R ubuntu.ubuntu /home/ubuntu +#echo $MYUID +#echo ${@} +# if [ ! -f /tmp/rustup.sh ] +# then +# gosu ubuntu bash -c "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rustup.sh" +# gosu ubuntu bash -c "chmod +x /tmp/rustup.sh" +# gosu ubuntu bash -c "/tmp/rustup.sh -y" +# fi +#exec gosu ubuntu '/home/ubuntu/.cargo/bin/rustup component add rust-src clippy rust-analysis rustfmt' +#exec gosu ubuntu '/home/ubuntu/.cargo/bin/rustup self update' +exec gosu ubuntu "${@}"