Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 181 additions & 0 deletions .bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi

if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'

alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi

# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi



dc() {
DC_FILE="${DOCKER_COMPOSE_FILE:-/home/ubuntu/deployment/docker-compose.yml}"
docker-compose -f "$DC_FILE" "$@"
}

#alias dc="docker-compose -f $DC_FILE"
alias logs="docker-compose -f $DC_FILE logs"
alias n-logs="docker-compose -f $DC_FILE logs nginx"
alias ms-logs="docker-compose -f $DC_FILE logs ethereum-reader"
alias ew-logs="docker-compose -f $DC_FILE logs ethereum-writer"
alias s-logs="docker-compose -f $DC_FILE logs signer"
alias ms-exec="docker-compose -f $DC_FILE exec ethereum-reader sh"
alias ew-exec="docker-compose -f $DC_FILE exec ethereum-writer sh"
alias s-exec="docker-compose -f $DC_FILE exec signer sh"
alias docker=podman
alias sync="rsync -aq --progress --exclude='.venv' --exclude='.git' $HOME/orbs-node-on-host/ $ORBS_ROOT"

# fix crontab -e to use VIM

if [ "$color_prompt" = yes ]; then
# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] $(parse_git_branch)\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt


export EDITOR=vim
export VISUAL=vim

# Enable history search with Up and Down arrows
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'

# need to install fzf - apt install fzf

# Use fzf for history search
fzf-history-widget() {
local selected num
selected=$(history | fzf --tac +s --query="$READLINE_LINE")
if [[ -n $selected ]]; then
READLINE_LINE=$(echo $selected | sed -E 's/^[ ]*[0-9]+[ ]+//')
READLINE_POINT=${#READLINE_LINE}
fi
}

bind -x '"\C-r": fzf-history-widget'

parse_git_branch() {
git branch 2>/dev/null | sed -n '/\* /s///p'
}

shopt -s histappend

# Save each command to the history file immediately and reload the history
if [[ -n "$PROMPT_COMMAND" ]]; then
PROMPT_COMMAND="$PROMPT_COMMAND; history -a; history -c; history -r"
else
PROMPT_COMMAND="history -a; history -c; history -r"
fi
4 changes: 2 additions & 2 deletions .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ jobs:
curl -f http://localhost/service/ethereum-reader/status

- name: Check manager's status is being served using legacy name (boyar)
run: |
curl -f http://localhost/service/boyar/status
run: | #used to be boyar
curl -f http://localhost/service/controller/status

- name: Check manager's status is being served using v4 name
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
config.json

*venv
home/
node_modules/
__pycache__/
ignore
uv.sh

.env
log.txt
registry-data
node_exporter*
96 changes: 78 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
ARG UBUNTU_VERSION=22.04

# Add sudo to make more like EC2 instance
RUN apt-get update && apt-get install -y software-properties-common python3 python3-pip sudo locales vim
RUN apt-get update && apt-get install -y fzf software-properties-common python3 python3-pip sudo locales vim curl rsync git

# EC2 instances usually have locale settings
RUN locale-gen en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
Expand All @@ -19,24 +20,83 @@ RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d
RUN useradd -ms /bin/bash ubuntu && \
echo "ubuntu ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/ubuntu && \
chmod 0440 /etc/sudoers.d/ubuntu

# Prepare to install podman 4.6.2
RUN key_url="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_${UBUNTU_VERSION}/Release.key" && \
sources_url="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_${UBUNTU_VERSION}" && \
echo "deb $sources_url/ /" | tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list && \
curl -fsSL $key_url | gpg --dearmor | tee /etc/apt/trusted.gpg.d/devel_kubic_libcontainers_unstable.gpg && \
apt-get update

ARG INSTALL_PACKAGES="podman fuse-overlayfs openssh-client ucpp"

# Update the package list and install required packages.
RUN apt-get install -y $INSTALL_PACKAGES && \
ln -s /usr/bin/ucpp /usr/local/bin/cpp && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Prepare necessary stuff to let podman run as rootless.

RUN echo "ubuntu:1:999\nubuntu:1001:64535" > /etc/subuid && \
echo "ubuntu:1:999\nubuntu:1001:64535" > /etc/subgid

ADD /containers.conf /etc/containers/containers.conf
ADD /podman-containers.conf /home/podman/.config/containers/containers.conf

RUN mkdir -p /home/ubuntu/.local/share/containers && \
chown ubuntu:ubuntu -R /home/ubuntu && \
chmod 644 /etc/containers/containers.conf

# Modify storage configuration for running with fuse-overlay storage inside the container
RUN sed -e 's|^#mount_program|mount_program|g' \
-e '/additionalimage.*/a "/var/lib/shared",' \
-e 's|^mountopt[[:space:]]*=.*$|mountopt = "nodev,fsync=0"|g' \
/usr/share/containers/storage.conf \
> /etc/containers/storage.conf

# Setup internal Podman to pass subscriptions down from host to internal container
RUN printf '/run/secrets/etc-pki-entitlement:/run/secrets/etc-pki-entitlement\n/run/secrets/rhsm:/run/secrets/rhsm\n' > /etc/containers/mounts.conf

# Define volumes for container storage
VOLUME /var/lib/containers
VOLUME /home/ubuntu/.local/share/containers

# Create shared directories and locks
RUN mkdir -p /var/lib/shared/overlay-images \
/var/lib/shared/overlay-layers \
/var/lib/shared/vfs-images \
/var/lib/shared/vfs-layers && \
touch /var/lib/shared/overlay-images/images.lock && \
touch /var/lib/shared/overlay-layers/layers.lock && \
touch /var/lib/shared/vfs-images/images.lock && \
touch /var/lib/shared/vfs-layers/layers.lock

# Copy the entrypoint script and make it executable
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

COPY .bashrc /home/ubuntu/.bashrc
RUN chown ubuntu:ubuntu /home/ubuntu/.bashrc

USER ubuntu

WORKDIR /home/ubuntu

# Shortcuts for docker-compose actions
RUN echo 'alias dc="docker-compose"' >> ~/.bashrc
RUN echo 'alias logs="docker-compose -f /home/ubuntu/deployment/docker-compose.yml logs"' >> ~/.bashrc
RUN echo 'alias n-logs="docker-compose -f /home/ubuntu/deployment/docker-compose.yml logs nginx"' >> ~/.bashrc
RUN echo 'alias ms-logs="docker-compose -f /home/ubuntu/deployment/docker-compose.yml logs ethereum-reader"' >> ~/.bashrc
RUN echo 'alias ew-logs="docker-compose -f /home/ubuntu/deployment/docker-compose.yml logs ethereum-writer"' >> ~/.bashrc
RUN echo 'alias s-logs="docker-compose -f /home/ubuntu/deployment/docker-compose.yml logs signer"' >> ~/.bashrc
RUN echo 'alias ms-exec="docker-compose -f /home/ubuntu/deployment/docker-compose.yml exec ethereum-reader sh"' >> ~/.bashrc
RUN echo 'alias ew-exec="docker-compose -f /home/ubuntu/deployment/docker-compose.yml exec ethereum-writer sh"' >> ~/.bashrc
RUN echo 'alias s-exec="docker-compose -f /home/ubuntu/deployment/docker-compose.yml exec signer sh"' >> ~/.bashrc

COPY --chown=ubuntu:ubuntu setup setup
COPY --chown=ubuntu:ubuntu manager manager
COPY --chown=ubuntu:ubuntu deployment deployment
COPY --chown=ubuntu:ubuntu logging logging

CMD ["/bin/bash"]
## Shortcuts for docker-compose actions
#RUN echo 'alias dc="docker-compose"' >> ~/.bashrc
#RUN echo 'alias logs="docker-compose -f /home/ubuntu/deployment/docker-compose.yml logs"' >> ~/.bashrc
#RUN echo 'alias n-logs="docker-compose -f /home/ubuntu/deployment/docker-compose.yml logs nginx"' >> ~/.bashrc
#RUN echo 'alias ms-logs="docker-compose -f /home/ubuntu/deployment/docker-compose.yml logs ethereum-reader"' >> ~/.bashrc
#RUN echo 'alias ew-logs="docker-compose -f /home/ubuntu/deployment/docker-compose.yml logs ethereum-writer"' >> ~/.bashrc
#RUN echo 'alias s-logs="docker-compose -f /home/ubuntu/deployment/docker-compose.yml logs signer"' >> ~/.bashrc
#RUN echo 'alias ms-exec="docker-compose -f /home/ubuntu/deployment/docker-compose.yml exec ethereum-reader sh"' >> ~/.bashrc
#RUN echo 'alias ew-exec="docker-compose -f /home/ubuntu/deployment/docker-compose.yml exec ethereum-writer sh"' >> ~/.bashrc
#RUN echo 'alias s-exec="docker-compose -f /home/ubuntu/deployment/docker-compose.yml exec signer sh"' >> ~/.bashrc

#COPY --chown=ubuntu:ubuntu setup setup
#COPY --chown=ubuntu:ubuntu manager manager
#COPY --chown=ubuntu:ubuntu deployment deployment
#COPY --chown=ubuntu:ubuntu logging logging

ENTRYPOINT ["/entrypoint.sh"]
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
registry:
@mkdir -p registry-data
@docker rm -f local-registry 2>/dev/null || true
docker run -d -p 6000:5000 -v $$(realpath registry-data):/var/lib/registry --name local-registry registry:2

build_docker_dev:
@docker buildx build --platform linux/arm64 -t test-ubuntu_arm64 .

run_docker_dev:
@if [ -n "$(vol)" ]; then \
docker run --privileged -v $$(pwd):/home/ubuntu/orbs-node-on-host -v $(vol):/home/ubuntu/orbs-node-remote-repo-simulate -p 80:80 --rm -it test-ubuntu_arm64; \
else \
docker run --privileged -v $$(pwd):/home/ubuntu/orbs-node-on-host -p 80:80 --rm -it test-ubuntu_arm64; \
fi
#@docker run --privileged -v $$(pwd):/home/ubuntu/orbs-node-on-host -p 80:80 --rm -it test-ubuntu_arm64
#@docker run --privileged -v $$(pwd):/opt/orbs-node -v $$(pwd)/manager/.venvdocker:/home/ubuntu/manager/.venv -v $$(pwd)/deployment:/home/ubuntu/deployment -v $$(pwd)/logging:/home/ubuntu/logging -v $$(pwd)/manager:/home/ubuntu/manager -v $$(pwd)/setup:/home/ubuntu/setup -p 80:80 --rm -it test-ubuntu_arm64
#@docker run --privileged -v $$(pwd):/opt/orbs-node-on-host -v $$(pwd)/manager/.venvdocker:/home/ubuntu/manager/.venv -v $$(pwd)/deployment:/home/ubuntu/deployment -v $$(pwd)/logging:/home/ubuntu/logging -v $$(pwd)/manager:/home/ubuntu/manager -v $$(pwd)/setup:/home/ubuntu/setup -p 80:80 --rm -it test-ubuntu_arm64

run_docker_dev2:
@docker run --privileged -v $$(pwd)/manager/.venvdocker:/home/ubuntu/manager/.venv -v $$(pwd)/deployment:/home/ubuntu/deployment -v $$(pwd)/logging:/home/ubuntu/logging -v $$(pwd)/manager:/home/ubuntu/manager -v $$(pwd)/setup:/home/ubuntu/setup -p 81:80 --rm -it test-ubuntu_arm64

run_node:
. setup/scripts/base.sh && \
docker-compose -f "$$DOCKER_COMPOSE_FILE" up -d

stop_node:
. setup/scripts/base.sh && \
docker-compose -f "$$DOCKER_COMPOSE_FILE" down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,32 @@ From Mac host, run `curl http://localhost/service/ethereum-reader/status`
#### Healthcheck always shows "starting"

[Podman uses systemd timers to run healtchecks periodically](https://github.com/containers/podman/issues/19326), which do not work in our dev Docker-in-Docker setup. As a workaround, you can run the command [`podman healthcheck run SERVICE`](https://docs.podman.io/en/v4.4/markdown/podman-healthcheck-run.1.html) to manually run a specific container healthcheck.


# New version - jordan notes: -

Run locally on MacOS:

Build the dev guardian image:

```make build_docker_dev```

Run the dev guardian image:

```make run_docker_dev```

Run the installation script after getting docker container prompt:

```source ./orbs-node-on-host/setup/install.sh --skip-req```

Inside the container, playing with docker-compose, make sure to run the dc command, not docker-compose, it's
an alias to docker-compose with mapping to the right docker-compose-dev.yml if any.

```dc up -d``` for example.

To synchronize changes made by local host to the container (e.g. after modifying a file in the host), run:

```sync```



12 changes: 12 additions & 0 deletions containers.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[containers]
netns="host"
userns="host"
ipcns="host"
utsns="host"
cgroupns="host"
cgroups="disabled"
log_driver = "k8s-file"
[engine]
cgroup_manager = "cgroupfs"
events_logger="file"
runtime="crun"
Loading
Loading