Skip to content

Commit

Permalink
Adding an entrypoint to be able to use the host UID inside the container
Browse files Browse the repository at this point in the history
  • Loading branch information
mosonyi committed Mar 17, 2023
1 parent abaf0e9 commit 9eb812e
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 8 deletions.
16 changes: 16 additions & 0 deletions worker/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cat <<'MSG'
_____ _ _ _
|_ _| | | (_) |
| | _ __ | |_ ___ __ _ _ __ _| |_ ___ ___
| | | '_ \| __/ _ \/ _` | '__| | __/ _ \/ _ \
_| |_| | | | || __/ (_| | | | | || __/ __/
|_____|_| |_|\__\___|\__, |_| |_|\__\___|\___|
__/ |
|___/
::::::::::::::::: Thanks for using Integritee's devevelpment environment! :::::::::::::::::

This comment has been minimized.

Copy link
@OverOrion

OverOrion Mar 17, 2023

Contributor

typo in development

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
37 changes: 29 additions & 8 deletions worker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down Expand Up @@ -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"]
28 changes: 28 additions & 0 deletions worker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
set -e

MYUID="${MYUID:-1000}"
MYGUID="${MYGUID:-1000}"
#echo ${MYUID}

This comment has been minimized.

Copy link
@OverOrion

OverOrion Mar 17, 2023

Contributor

Commented out code should be removed, unless needed for some reason.


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

This comment has been minimized.

Copy link
@OverOrion

OverOrion Mar 17, 2023

Contributor

Same here, until line 28.

#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 "${@}"

0 comments on commit 9eb812e

Please sign in to comment.