arcade-mcp/docker/Makefile
Sam Partee 52d82a2789
Refactor Docker Build Process (#78)
This PR improves the Docker build process by shifting from building the
project within the Docker image to using pre-built wheels. The main
changes are:

1. **Updated Makefile:**
- **`VERSION` Variable:** Set to `0.1.0.dev0` to reflect the new default
development version.
   - **`docker` Target:**
- Added steps to build the Arcade and toolkit wheels before building the
Docker image.
- Exports the required extras (`fastapi`, `evals`) to a
`requirements.txt` file.
   - **`full-dist` Target:**
     - Builds distributions for the main project and all toolkits.
     - Copies all the built wheels to a centralized `./dist` directory.
   - **`clean-dist` Target:**
- Cleans build artifacts from `./dist`, `arcade/dist`, and
`toolkits/*/dist` directories.

2. **Modified Dockerfile:**
- **Copy Pre-built Wheels:** Adjusted to copy wheels and the
`requirements.txt` from the `./dist` directory into the Docker image.
   - **Installation Process:**
     - Installs the Arcade wheel with the necessary extras.
- Installs toolkits from the copied wheel files, eliminating the need to
build them inside the Docker image.
- **Simplification:** Removed unnecessary commands, such as installing
build tools and copying the entire codebase, to streamline the
Dockerfile.

3. **Toolkits `pyproject.toml` Updates:**
- Changed the `arcade-ai` dependency version from `^0.1.0` to `0.1.*` in
all toolkit `pyproject.toml` files to ensure compatibility with the new
versioning scheme.

4. **Docker Makefile Adjustments:**
- Set the `VERSION` variable to `0.1.0.dev0` to align with the main
Makefile.
- Ensures consistent versioning across Docker-related build processes.

**Benefits:**

- **Efficiency:** Building wheels outside the Docker context reduces the
Docker image build time and resource consumption. overall docker image
size reduced by **1Gb**!!!
- **Reliability:** Using pre-built wheels ensures consistency across
different environments and simplifies dependency management.
- **Maintainability:** The Dockerfile and Makefiles are cleaner and more
straightforward, making them easier to understand and maintain.


**Notes:**

- Developers should run `make docker` to build and run the Docker
container using the new process.
- Ensure that any CI/CD pipelines are updated to accommodate these
changes in the build process. @sdreyer
2024-10-01 19:05:13 -07:00

63 lines
2.3 KiB
Makefile

VENDOR ?= ArcadeAI
PROJECT ?= ArcadeAI
SOURCE ?= https://github.com/ArcadeAI/arcade-ai
LICENSE ?= MIT
DESCRIPTION ?= "Arcade AI for LLM Tool Serving"
REPOSITORY ?= arcadeai/arcade-ai
ECR_ENDPOINT ?= 471112909428.dkr.ecr.us-east-1.amazonaws.com
VERSION ?= 0.1.0.dev0
COMMIT ?= $(shell git describe --dirty --always --abbrev=15)
BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
IMAGE_NAME ?= actor
PORT ?= 8002
.PHONY: docker-build
docker-build: ## Build the Docker container
@echo "🛠️ Building Docker image ($(VERSION)).."
@echo "- Commit: $(COMMIT)"
@echo "- Build Date: $(BUILD_DATE)"
@docker build --build-arg PORT=$(PORT) -f Dockerfile -t $(REPOSITORY):$(VERSION) .. \
--build-arg PORT=$(PORT) \
--build-arg VERSION="$(VERSION)" \
--build-arg COMMIT="$(COMMIT)" \
--build-arg BUILD_DATE="$(BUILD_DATE)" \
--label=org.opencontainers.image.vendor="$(VENDOR)" \
--label=org.opencontainers.image.title="$(PROJECT)" \
--label=org.opencontainers.image.revision="$(COMMIT)" \
--label=org.opencontainers.image.version="$(VERSION)" \
--label=org.opencontainers.image.created="$(BUILD_DATE)" \
--label=org.opencontainers.image.source="$(SOURCE)" \
--label=org.opencontainers.image.licenses="$(LICENSE)" \
--label=org.opencontainers.image.description=$(DESCRIPTION)
.PHONY: docker-run
docker-run: ## Run the Docker container
@echo "\n🚀 Run the container with the following ..."
@echo ">>> docker run -d -p $(PORT):$(PORT) $(REPOSITORY):$(VERSION)"
.PHONY: publish-ecr
publish-ecr:
@echo "🚚 Pushing the Agent image to ECR.."
@docker tag $(REPOSITORY):$(VERSION) $(ECR_ENDPOINT)/$(REPOSITORY):$(VERSION)
@echo "- pushing $(ECR_ENDPOINT)/$(REPOSITORY):$(VERSION)"
@docker push $(ECR_ENDPOINT)/$(REPOSITORY):$(VERSION)
@echo $(VERSION) | grep -q $(RC_PART) || { \
docker tag $(REPOSITORY):$(VERSION) $(ECR_ENDPOINT)/$(REPOSITORY):latest; \
echo "- pushing $(ECR_ENDPOINT)/$(REPOSITORY):latest"; \
docker push $(ECR_ENDPOINT)/$(REPOSITORY):latest; \
}
.PHONY: ecr-login
ecr-login: # Login to ECR
@aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $(ECR_ENDPOINT)
.PHONY: help
help:
@echo "🛠️ Actor Docker Commands:\n"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help