Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: running Mesa in Docker with Schelling model #2524

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ FROM python:bookworm
LABEL maintainer="rht <rhtbot@protonmail.com>"
wang-boyu marked this conversation as resolved.
Show resolved Hide resolved
AdamZh0u marked this conversation as resolved.
Show resolved Hide resolved

# To use this Dockerfile:
# 1. `docker build . -t mymesa_image`
# 2. `docker run --name mymesa_instance -p 8765:8765 -it mymesa_image`
# 1. `docker build . -t mesa_image`
# 2. `docker run --name mesa_instance -p 8765:8765 -it mesa_image`
# 3. In your browser, visit http://127.0.0.1:8765
#
# Currently, this Dockerfile defaults to running the Schelling model, as an
Expand All @@ -19,7 +19,7 @@ LABEL maintainer="rht <rhtbot@protonmail.com>"
# `docker run --name mymesa_instance -p 8765:8765 -e MODEL_DIR=/mesa-examples/examples/sugarscape_cg -it mymesa_image`
# Note: the model directory MUST contain an app.py file.

ENV MODEL_DIR=/mesa-examples/examples/schelling_experimental
ENV MODEL_DIR=/opt/mesa/mesa/examples/basic/schelling

# Don't buffer output:
# https://docs.python.org/3.10/using/cmdline.html?highlight=pythonunbuffered#envvar-PYTHONUNBUFFERED
Expand All @@ -29,10 +29,11 @@ WORKDIR /opt/mesa

COPY . /opt/mesa

RUN cd / && git clone https://github.com/projectmesa/mesa-examples.git

EXPOSE 8765/tcp

RUN pip3 install -e /opt/mesa
RUN pip3 install -e /opt/mesa[rec]

CMD ["sh", "-c", "cd $MODEL_DIR && solara run app.py --host=0.0.0.0"]

# To check file system:
# docker exec -it mesa_instance bash
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ services:
# within the current directory.
# E.g. if it is at my-model, then you specify it as
# /opt/mesa/my-model.
MODEL_DIR: /mesa-examples/examples/schelling_experimental
MODEL_DIR: /opt/mesa/mesa/examples/basic/schelling
ports:
- 8765:8765
Loading