# % 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 -v ~/.ssh:/home/$USERNAME/.ssh:ro factor-alpine:latest" 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 lldb || \ (sleep 5 && apk add --no-cache \ 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 lldb) # 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 # 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 # Build Factor RUN ./build.sh deps-apk # 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 node -v && npm -v && \ npm install -g @anthropic-ai/claude-code # Set up environment ENV PATH="/home/${USERNAME}/.npm-global/bin:/home/${USERNAME}/factor:${PATH}" # Default command with zsh CMD ["/bin/zsh"]