arcade-mcp/docker/Dockerfile
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

48 lines
1.1 KiB
Docker

# Use a lightweight Python image
FROM python:3.10-slim
# Define build arguments with default values
ARG PORT=8001
ARG HOST=0.0.0.0
ARG VERSION=0.1.0
# Set environment variables using the build arguments
ENV PORT=${PORT}
ENV HOST=${HOST}
ENV VERSION=${VERSION}
ENV OTEL_ENABLE=false
ENV ARCADE_WORK_DIR=/app
# Install system dependencies
RUN apt-get update && apt-get install -y \
apt-utils \
build-essential \
libssl-dev \
libffi-dev \
python3-dev \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app/arcade
# Copy the parent directory contents into the container
COPY ./dist .
# Install the wheel with extras (not evals for now)
RUN python -m pip install ./arcade_ai-${VERSION}-py3-none-any.whl
RUN python -m pip install -r ./requirements.txt
# Install toolkits from the toolkits directory
RUN set -e; \
for toolkit in ./toolkits/*; do \
echo "Installing toolkit $toolkit"; \
python -m pip install $toolkit; \
done
# Expose the port
EXPOSE $PORT
# Run the arcade actorup (hidden cli command)
CMD arcade actorup --host $HOST --port $PORT