Skip to content

Commit

Permalink
odin updates
Browse files Browse the repository at this point in the history
  • Loading branch information
danbryan committed Oct 29, 2024
1 parent f1b3e3a commit b8a3a0b
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 61 deletions.
1 change: 1 addition & 0 deletions injectived/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go-sdk 1.22.4
42 changes: 42 additions & 0 deletions injectived/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ARG CHAIN_VERSION=v1.13.2
ARG DEBIAN_VERSION=bookworm-slim
ARG UID=1025
ARG USER=heighliner

# Stage 1: Extract the source binary.
FROM public.ecr.aws/l9h3g6c6/injective-core:${CHAIN_VERSION} AS source

# Final Stage: Use a specific version of Debian as the base image
FROM debian:${DEBIAN_VERSION}
ARG UID
ARG USER
WORKDIR /home/${USER}

# Install necessary tools and libraries, create user
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl jq coreutils libonig5 libcurl4 libgcc1 libnghttp2-14 brotli openssl sudo \
&& groupadd -g ${UID} ${USER} \
&& useradd -u ${UID} -m -g ${USER} -s /bin/bash ${USER} \
&& echo "${USER} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USER} \
&& chmod 0440 /etc/sudoers.d/${USER} \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Use build arguments for dynamic labeling
ARG VERSION
LABEL org.opencontainers.image.source="https://github.com/defiantlabs/injectived:${VERSION}"

# Copy the injectived binary and required library from the source image
COPY --from=source /usr/local/bin/injectived /bin/injectived
COPY --from=source /usr/lib/libwasmvm.x86_64.so /usr/lib/libwasmvm.x86_64.so
# Set correct permissions for the library
RUN chmod 755 /usr/lib/libwasmvm.x86_64.so

# Set the library path for runtime linking
ENV LD_LIBRARY_PATH=/usr/lib

# Switch to non-root user
USER ${USER}

# Set default entrypoint and command (optional, if applicable)
ENTRYPOINT ["/bin/bash"]
100 changes: 41 additions & 59 deletions odind/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,65 +1,47 @@
FROM golang:1.22 AS build-env

ARG TARGETPLATFORM
ARG BUILD_TAGS=netgo
ARG VERSION
ARG LD_FLAGS=-linkmode=external \
-extldflags '-Wl,-z,muldefs -static'

# Install cli tools for building and final image
RUN apt-get update && \
apt-get install -y make git bash gcc linux-headers-amd64 libudev-dev libncurses-dev openssh-client curl jq coreutils

# Build
WORKDIR /go/src/github.com/ODIN-PROTOCOL
RUN git clone https://github.com/ODIN-PROTOCOL/odin-core.git
WORKDIR /go/src/github.com/ODIN-PROTOCOL/odin-core
RUN git fetch
RUN git checkout ${VERSION}
# WORKDIR /go/src/github.com/ODIN-PROTOCOL/odin-core/cmd/odind
WORKDIR /go/src/github.com/ODIN-PROTOCOL/odin-core

# Install CosmWasm.
RUN set -eux; \
WASM_VERSION=$(go list -m all | grep github.com/CosmWasm/wasmvm | awk '{print $NF}'); \
echo ${WASM_VERSION} ;\
if [ ! -z "${WASM_VERSION}" ]; then \
wget -O /lib/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASM_VERSION}/libwasmvm_muslc.$(uname -m).a; \
fi; \
go mod download;

# Build Chain Binary
RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ] ; then \
make install ; \
fi

RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ] ; then \
make install ; \
fi

# Use Debian Buster slim for the final image
FROM debian:bookworm-slim

WORKDIR /bin
# Declare build arguments at the top of the Dockerfile
ARG ODIN_VERSION=v0.9.4
ARG YODA_VERSION=v0.10.0
ARG ALPINE_VERSION=3.20
ARG UID=1025
ARG USER=heighliner

# Stage 1: Extract the odind binary from the odinprotocol/core image
FROM odinprotocol/core:${ODIN_VERSION} AS odin-source

# Final Stage: Use a specific version of Alpine as the base image
FROM alpine:${ALPINE_VERSION}

# Declare build arguments for reuse
ARG UID
ARG USER
ARG YODA_VERSION

# Set working directory
WORKDIR /home/${USER}

# Install necessary tools and libraries, create user, and set up sudoers
RUN apk add --no-cache \
curl jq coreutils oniguruma libcurl libgcc nghttp2-libs brotli openssl sudo \
&& addgroup -g ${UID} -S ${USER} \
&& adduser -u ${UID} -S ${USER} -G ${USER} \
&& echo "${USER} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USER} \
&& chmod 0440 /etc/sudoers.d/${USER}

# Use build argument for dynamic labeling
ARG VERSION
LABEL org.opencontainers.image.source="https://github.com/defiantlabs/odind:${VERSION}"

COPY --from=build-env /go/bin/odind /bin
COPY --from=build-env /go/bin/yoda /bin
COPY --from=build-env /usr/bin/ldd /bin/ldd
COPY --from=build-env /usr/bin/curl /bin/curl
COPY --from=build-env /usr/bin/jq /bin/jq
COPY --from=build-env /go/pkg/mod/github.com/odin-protocol/go-owasm@v*/api/libgo_owasm.so /usr/lib/
# COPY --from=build-env /go/pkg/mod/github.com/!cosm!wasm/wasmvm@v*/internal/api/libwasmvm.x86_64.so /usr/lib/

RUN apt-get update && apt-get install -y ca-certificates
# Copy the odind binary from the source image
COPY --from=odin-source /usr/bin/odind /bin/odind
# COPY --from=odin-source /usr/bin/yoda /bin/yoda

RUN adduser --system --uid 1137 defiant
RUN addgroup --system --gid 1137 defiant
# Download the yoda binary and save it to /bin
RUN curl -L -o /bin/yoda \
https://github.com/ODIN-PROTOCOL/odin-core/releases/download/${YODA_VERSION}/yoda-${YODA_VERSION}-linux-amd64 \
&& chmod +x /bin/yoda

# Create /home/operator/cosmos and add symlink before switching user
RUN mkdir -p /home/defiant/cosmos
# Switch to non-root user
USER ${USER}

WORKDIR /home/defiant
RUN chown -R defiant /home/defiant
USER defiant
# Set default entrypoint and command (if applicable)
ENTRYPOINT ["/bin/sh"]
32 changes: 32 additions & 0 deletions odind/Dockerfile_new
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Set build arguments for ODIN and Alpine versions, user ID, and user name
ARG ODIN_VERSION=26.0.0
ARG ALPINE_VERSION=3.20
ARG UID=1025
ARG USER=heighliner

FROM alpine:${ALPINE_VERSION}
ARG UID
ARG USER

# Set working directory
WORKDIR /home/${USER}

# Install necessary runtime tools and libraries
RUN apk add --no-cache curl jq coreutils oniguruma libcurl libgcc \
nghttp2-libs brotli openssl sudo

# Create user and add to sudoers
RUN addgroup -g ${UID} -S ${USER} \
&& adduser -u ${UID} -S ${USER} -G ${USER} \
&& echo "${USER} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USER} \
&& chmod 0440 /etc/sudoers.d/${USER}

RUN wget https://github.com/ODIN-PROTOCOL/odin-core/releases/download/v0.9.3/odind-v0.9.3-linux-amd64 -O /bin/odind && chmod +x /bin/odind

# Switch to non-root user
USER ${USER}

# Set default entrypoint
ENTRYPOINT ["/bin/sh"]


4 changes: 2 additions & 2 deletions osmosisd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Declare build arguments at the top of the Dockerfile
ARG OSMOSIS_VERSION=26.0.0
ARG ALPINE_VERSION=3.20
ARG UID=1137
ARG USER=defiant
ARG UID=1025
ARG USER=heighliner

# Stage 1: Extract the osmosisd binary from the osmolabs/osmosis image
FROM osmolabs/osmosis:${OSMOSIS_VERSION} AS source
Expand Down
38 changes: 38 additions & 0 deletions ton/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Use Ubuntu 22.04 as the base image
FROM ubuntu:22.04

# Arguments for setting user ID and username
ARG UID=1000
ARG USER=ubuntu

# Set environment variables for running systemd in Docker
ENV container docker
ENV DEBIAN_FRONTEND=noninteractive

# Install necessary packages
RUN apt-get update -y && \
apt-get install -y systemd sudo net-tools curl wget jq python3-pip && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Create a user and group with the specified UID
RUN groupadd -g ${UID} ${USER} && \
useradd -u ${UID} -m -g ${USER} -s /bin/bash ${USER} && \
echo "${USER} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USER} && \
chmod 0440 /etc/sudoers.d/${USER}

# Set the working directory
WORKDIR /home/${USER}

# Set up the directories required for systemd
RUN mkdir -p /run/systemd && \
echo 'docker' > /run/systemd/container

# Set the volume for cgroup and systemd runtime
VOLUME [ "/sys/fs/cgroup" ]

# Switch to non-root user
USER ${USER}

# Set default command to start systemd
CMD ["/sbin/init"]

0 comments on commit b8a3a0b

Please sign in to comment.