From 03a43b5cf743eb883c958d6cd9f7a03866652fe3 Mon Sep 17 00:00:00 2001 From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com> Date: Sun, 6 Oct 2024 21:03:13 -0400 Subject: [PATCH] install packages for contracts, and general cleanup --- Dockerfile | 46 ++++++++++++++++++++++-------------- docker-compose.yaml | 4 ++-- node-install.sh | 57 --------------------------------------------- 3 files changed, 31 insertions(+), 76 deletions(-) delete mode 100755 node-install.sh diff --git a/Dockerfile b/Dockerfile index c775bcb5..db229605 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,41 +1,53 @@ -# Build the Go binary in a separate stage utilizing Makefile +# Build stage FROM golang:1.22 AS builder -# Install necessary packages for the final image +WORKDIR /app + +# Install Node.js and Yarn RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ - curl sudo gpg lsb-release software-properties-common \ + curl gpg \ && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \ - && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor -o /usr/share/keyrings/yarn-archive-keyring.gpg \ - && apt remove cmdtest \ - && echo "deb [signed-by=/usr/share/keyrings/yarn-archive-keyring.gpg] https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ - && apt-get update && apt-get install -y git yarn apt-utils + && apt-get install -y nodejs \ + && npm install -g yarn -WORKDIR /app -COPY go.mod go.sum ./ -RUN go mod download +# Copy the entire project COPY . . +# Install contract dependencies +RUN cd contracts && yarn install + +# Build the Go binary RUN make build -# Use the official Ubuntu 22.04 image as a base for the final image -FROM ubuntu:22.04 AS base +# Final stage +FROM ubuntu:22.04 + +# Install necessary packages +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + nodejs npm \ + && npm install -g yarn + +# Create the 'masa' user and set up the home directory +RUN useradd -m -s /bin/bash masa && \ + mkdir -p /home/masa/.masa && \ + chown -R masa:masa /home/masa +# Copy the built binary and set permissions COPY --from=builder /app/bin/masa-node /usr/bin/masa-node RUN chmod +x /usr/bin/masa-node -# Create the 'masa' user and set up the home directory -RUN useradd -m -s /bin/bash masa && mkdir -p /home/masa/.masa && chown -R masa:masa /home/masa +# Copy contracts directory including node_modules +COPY --from=builder --chown=masa:masa /app/contracts /home/masa/contracts # Switch to user 'masa' for following commands USER masa WORKDIR /home/masa -# Copy the .env file into the container +# Copy the .env file COPY --chown=masa:masa .env . # Expose necessary ports EXPOSE 4001 8080 -# Set default command to start the Go application - +# Set default command to start the MASA node CMD /usr/bin/masa-node --bootnodes="$BOOTNODES" --env="$ENV" --validator="$VALIDATOR" --cachePath="$CACHE_PATH" \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 8352b757..ea43ac6c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -14,8 +14,8 @@ services: FILE_PATH: "${FILE_PATH}" VALIDATOR: "${VALIDATOR}" CACHE_PATH: "${CACHE_PATH}" - TWITTER_PASS: "${TWITTER_PASS}" - TWITTER_USER: "${TWITTER_USER}" + TWITTER_PASSWORD: "${TWITTER_PASSWORD}" + TWITTER_USERNAME: "${TWITTER_USERNAME}" TWITTER_2FA_CODE: "${TWITTER_2FA_CODE}" TWITTER_SCRAPER: "${TWITTER_SCRAPER}" volumes: diff --git a/node-install.sh b/node-install.sh deleted file mode 100755 index e3f20fed..00000000 --- a/node-install.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -# Create the 'masa' user and set up home directory -useradd -m masa - -# set RPC_URL -RPC_URL=https://ethereum-sepolia.publicnode.com - -# Append the RPC_URL to the masa user's .bash_profile -echo "export RPC_URL=${RPC_URL}" | tee -a /home/masa/.bash_profile - -# Set permissions for the masa user's home directory -chown masa:masa /home/masa/.bash_profile - -# Install Node.js and Yarn -curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - -curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor -o /usr/share/keyrings/yarn-archive-keyring.gpg -echo "deb [signed-by=/usr/share/keyrings/yarn-archive-keyring.gpg] https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list -apt-get update -y && apt-get install -y yarn nodejs jq - -# Build go binary -make build -cp masa-node /usr/local/bin/masa-node -chmod +x /usr/local/bin/masa-node - -# Determine global npm modules path and set NODE_PATH -GLOBAL_NODE_MODULES=$(npm root -g) -export NODE_PATH=$GLOBAL_NODE_MODULES - -MASANODE_CMD="/usr/bin/masa-node --port=4001 --udp=true --tcp=false --start --bootnodes=${BOOTNODES}" - -# Create a systemd service file for masa-node -cat <