Skip to content

Commit cf3386a

Browse files
committed
Add Dockerfile and Makefile
1 parent 1f08698 commit cf3386a

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Use an official Python image as the base
2+
FROM python:3.12-slim
3+
4+
# Set the working directory inside the container
5+
WORKDIR /app
6+
7+
# Install system dependencies
8+
RUN apt-get update && apt-get install -y --no-install-recommends \
9+
build-essential \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
# Copy the project files into the container
13+
COPY . /app
14+
15+
# Install Python dependencies
16+
RUN pip install --root-user-action=ignore -e .
17+
18+
# Expose the project directory as a volume
19+
VOLUME ["/app"]
20+
21+
# Set the entry point to the openevolve-run.py script
22+
ENTRYPOINT ["python", "/app/openevolve-run.py"]

Makefile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Variables
2+
PROJECT_DIR := $(shell pwd)
3+
DOCKER_IMAGE := openevolve
4+
VENV_DIR := $(PROJECT_DIR)/env
5+
PYTHON := $(VENV_DIR)/bin/python
6+
PIP := $(VENV_DIR)/bin/pip
7+
8+
# Default target
9+
.PHONY: all
10+
all: install test
11+
12+
# Create and activate the virtual environment
13+
.PHONY: venv
14+
venv:
15+
python3 -m venv $(VENV_DIR)
16+
17+
# Install Python dependencies in the virtual environment
18+
.PHONY: install
19+
install: venv
20+
$(PIP) install -e .
21+
22+
# Run Black code formatting
23+
.PHONY: lint
24+
lint: venv
25+
$(PYTHON) -m black openevolve examples tests
26+
27+
# Run tests using the virtual environment
28+
.PHONY: test
29+
test: venv
30+
$(PYTHON) -m unittest discover -s tests -p "test_*.py"
31+
32+
# Build the Docker image
33+
.PHONY: docker-build
34+
docker-build:
35+
docker build -t $(DOCKER_IMAGE) .
36+
37+
# Run the Docker container with the example
38+
.PHONY: docker-run
39+
docker-run:
40+
docker run --rm -v $(PROJECT_DIR):/app $(DOCKER_IMAGE) examples/function_minimization/initial_program.py examples/function_minimization/evaluator.py --config examples/function_minimization/config.yaml --iterations 1000

0 commit comments

Comments
 (0)