Paste: container 7/25
Author: | erg |
Mode: | factor |
Date: | Fri, 25 Jul 2025 20:15:20 |
Plain Text |
# cat build-factor-container.sh Dockerfile
#!/bin/bash
# Get configuration from local setup
GIT_USER_NAME=$(git config --get user.name)
GIT_USER_EMAIL=$(git config --get user.email)
USERNAME=$(whoami)
if [ -z "$GIT_USER_NAME" ] || [ -z "$GIT_USER_EMAIL" ]; then
echo "Error: Git user name or email not configured"
echo "Please run: git config --global user.name 'Your Name'"
echo " git config --global user.email 'your.email@example.com'"
exit 1
fi
echo "Building Factor container with:"
echo " Username: $USERNAME"
echo " Git user: $GIT_USER_NAME"
echo " Git email: $GIT_USER_EMAIL"
# Build the container
container build \
--build-arg USERNAME="$USERNAME" \
--build-arg GIT_USER_NAME="$GIT_USER_NAME" \
--build-arg GIT_USER_EMAIL="$GIT_USER_EMAIL" \
-t factor-alpine:latest \
.
if [ $? -eq 0 ]; then
echo "Container built successfully!"
echo ""
echo "To run the container with SSH key access:"
echo "container run -it --memory=32gb -v ~/.ssh:/home/$USERNAME/.ssh:rw -v ~/factor:/home/$USERNAME/factor:rw factor-alpine:latest"
echo "container exec -it 9f4fa5ba-77a9-4904-8258-1bc5e10ac09f /bin/zsh"
echo "gdb --args ./factor -i=boot.unix-arm.64.image"
echo "gdb -batch -ex 'run' -ex 'bt' --args ./factor -i=boot.unix-arm.64.image"
else
echo "Container build failed!"
exit 1
fi
FROM node:24.4.1-alpine AS node
FROM alpine:latest
# Copy Node.js from the node image
COPY --from=node /usr/lib /usr/lib
COPY --from=node /usr/local/lib /usr/local/lib
COPY --from=node /usr/local/include /usr/local/include
COPY --from=node /usr/local/bin /usr/local/bin
# Install base dependencies in one layer with retry logic
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/main \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/community \
bash zsh git make gcc g++ libc-dev pango-dev libx11-dev gtk+2.0-dev \
wget rlwrap clang tmux screen openssl-dev glu-dev mesa-dev \
openssh-client sudo curl ripgrep neovim gdb
# Create user with sudo privileges (username configurable via build arg)
ARG USERNAME=erg
RUN adduser -D -s /bin/zsh ${USERNAME} && \
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Switch to user
USER ${USERNAME}
WORKDIR /home/${USERNAME}
# Set up git configuration (email and name will be passed as build args)
ARG GIT_USER_NAME
ARG GIT_USER_EMAIL
RUN git config --global user.name "${GIT_USER_NAME}" && \
git config --global user.email "${GIT_USER_EMAIL}"
# Create .ssh directory for SSH key mounting
RUN mkdir -p ~/.ssh && chmod 700 ~/.ssh
# Mount the local factor into the container
RUN mkdir -p ~/factor
# Clone factor repository #RUN git clone https://github.com/factor/factor.git /home/${USERNAME}/factor
WORKDIR /home/${USERNAME}/factor
# Add your personal remote
#RUN git remote add gifti https://github.com/gifti258/factor
# Configure npm to use user directory for global packages
RUN mkdir -p ~/.npm-global && \
npm config set prefix '~/.npm-global' && \
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc
# Verify Node.js installation and install claude-code
RUN npm install -g @anthropic-ai/claude-code
RUN npm install -g @google/gemini-cli
RUN npm install -g @openai/codex
# Set up environment
ENV PATH="/home/${USERNAME}/.npm-global/bin:/home/${USERNAME}/factor:${PATH}"
# Default command with zsh
CMD ["/bin/zsh"]
New Annotation