Optimize Dockerfile: combine RUN commands, clear caches, add .dockerignore

- Combine apt-get update and install into single RUN with cache clearing
- Remove APT lists after installation
- Add --no-cache-dir to pip install
- Add --prefer-offline --no-audit to npm install
- Create .dockerignore to exclude unnecessary files from build context
- Update docker-publish.yml workflow to tag images with release names
- Ensure buildx caching is used (type=gha)
This commit is contained in:
Bryan Cross
2026-03-30 15:19:52 -05:00
parent ea342f2382
commit 8210e7aba6
3 changed files with 98 additions and 15 deletions

View File

@@ -3,11 +3,73 @@
.gitignore
.gitmodules
# Dependencies
node_modules
# CI/CD
# GitHub
.github
# Environment files
.env
# Python
__pycache__
*.py[cod]
*$py.class
*.so
.Python
.pytest_cache
.mypy_cache
.ruff_cache
*.egg-info
.eggs
# Virtual environments
.venv
venv/
ENV/
env/
# IDE
.vscode
.idea
*.swp
*.swo
*~
# Environment files (secrets)
.env
.env.*
!.env.example
# Logs and data
logs/
data/
tmp/
temp_vision_images/
testlogs
wandb/
# Test files
tests/
*.test.py
*.spec.py
# Documentation
*.md
!README.md
# CI/CD
*.yml
!package.json
# Development files
examples/
result
.direnv/
# Release scripts
.release_notes.md
mini-swe-agent/
# Nix
.direnv/
result
# Skills hub
skills/.hub/
ignored/

View File

@@ -5,6 +5,8 @@ on:
branches: [main]
pull_request:
branches: [main]
release:
types: [published]
concurrency:
group: docker-${{ github.ref }}
@@ -41,13 +43,13 @@ jobs:
nousresearch/hermes-agent:test --help
- name: Log in to Docker Hub
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'release'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push image
- name: Push image (main branch)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
@@ -59,3 +61,17 @@ jobs:
nousresearch/hermes-agent:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Push image (release)
if: github.event_name == 'release'
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
tags: |
nousresearch/hermes-agent:latest
nousresearch/hermes-agent:${{ github.event.release.tag_name }}
nousresearch/hermes-agent:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

View File

@@ -1,20 +1,25 @@
FROM debian:13.4
RUN apt-get update
RUN apt-get install -y nodejs npm python3 python3-pip ripgrep ffmpeg gcc python3-dev libffi-dev
# Install system dependencies in one layer, clear APT cache
RUN apt-get update && \
apt-get install -y --no-install-recommends \
nodejs npm python3 python3-pip ripgrep ffmpeg gcc python3-dev libffi-dev && \
rm -rf /var/lib/apt/lists/*
COPY . /opt/hermes
WORKDIR /opt/hermes
RUN pip install -e ".[all]" --break-system-packages
RUN npm install
RUN npx playwright install --with-deps chromium
# Install Python and Node dependencies in one layer, no cache
RUN pip install --no-cache-dir -e ".[all]" --break-system-packages && \
npm install --prefer-offline --no-audit && \
npx playwright install --with-deps chromium
WORKDIR /opt/hermes/scripts/whatsapp-bridge
RUN npm install
RUN npm install --prefer-offline --no-audit
WORKDIR /opt/hermes
RUN chmod +x /opt/hermes/docker/entrypoint.sh
ENV HERMES_HOME=/opt/data
VOLUME [ "/opt/data" ]
ENTRYPOINT [ "/opt/hermes/docker/entrypoint.sh" ]
ENTRYPOINT [ "/opt/hermes/docker/entrypoint.sh" ]