codetojoy / WarO_Python

Apache License 2.0
0 stars 0 forks source link

Dockerfile #2

Closed codetojoy closed 4 years ago

codetojoy commented 4 years ago

from Evan

Creating a Dockerfile much easier. Let the machine do the work.

FROM python:3.6

RUN pip install pytest

ENV PYTHONPATH /app/waro

ADD waro /app/waro
ADD tests /app/tests
ADD config.json /app/config.json
ADD config.interactive.json /app/config.interactive.json
ADD config.non.interactive.json /app/config.non.interactive.json

WORKDIR /app

ENTRYPOINT [ "python" ]

Then do the following:

docker build -t waro . # build image with Waro in it, and tag it `waro`
docker run waro waro/main.py config.json # Run continer based on `waro` image (in the container, this translates to `python waro/main.py config.json`)
docker run waro -m pytest # run the tests (in the container, this translates to `python -m pytest`)

Basically, running docker run waro will run a container and immediately execute "python" (as per ENTRYPOINT in the Dockerfile)

If need be, you can mount extra config files into the container to run other war-o strategies.

codetojoy commented 4 years ago

I tried this, but using a "console strategy" leads to I/O problems (?)...

These are solved in run.sh so presumably the instructions above could use that as well.

evanepio commented 4 years ago

Whoops, sorry about that.

docker run -it waro waro/main.py config.interactive.json

You need to tell docker you want interactive terminal, so you need the i (allow stdin maybe) and t (allocate TTY I think?) flags. You'll only need the -it part to have interaction with terminal.