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

Dockerfile for ROSE #428

Merged
merged 3 commits into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/classroom
/docs
Makefile
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Generate a container that generates requirements.txt
ARG PY_VERSION=3.7
FROM python:${PY_VERSION} as source

ARG DEV

ENV ENABLE_PIPENV=true

# Install pipenv
RUN pip install --upgrade pipenv

COPY Pipfile ./Pipfile

# Generate requirements.txt file from Pipfile
RUN if [ -z ${DEV} ]; \
then \
pipenv lock -r > requirements.txt; \
else \
pipenv lock --dev -r > requirements.txt; \
fi

# Generate work image
ARG PY_VERSION
FROM python:${PY_VERSION}

# Project maintainer
LABEL maintainer="frolland@redhat.com"

# Copy pipfile to default WORKDIR
COPY --from=source requirements.txt ./requirements.txt

# Install dependencies
RUN pip install -r requirements.txt

# Copy application to default WORKDIR
COPY . ./

# Server port
EXPOSE 8880

# Server command
CMD [ "run", "python", "rose-server"]
40 changes: 28 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ Refer to our GitHub pages for the course materials and additional resources:
- [Read](https://opensource.com/education/15/9/open-source-education-israel) an article by Laura Novich
on [opensource.com](https://opensource.com)


## Requirements

Once we're in the ROSE directory, we need to verify we have pipenv installed.
Expand All @@ -61,7 +60,7 @@ your user:

## Getting started

The following commands should be performed only once; after creating the environment you will be connecting to the same environment each time you open a new session.
The following commands should be performed only once; after creating the environment you will be connecting to the same environment each time you open a new session.

Use pipenv to create a virtual environment and to install the rest of the dependencies:

Expand All @@ -70,7 +69,7 @@ Use pipenv to create a virtual environment and to install the rest of the depend
You can also install packages from your distribution, but they may be
too old.

After creating the environment, we want to activate and enter our environment:
After creating the environment, we want to activate and enter our environment:

pipenv shell

Expand All @@ -94,18 +93,30 @@ For running the same track for all drivers (instead or random) start the server

Open a browser at http://\<server-address\>:8880 to view and control the game.

### Running the server in Docker

Build the Docker image:

docker build -t rose_server .

Run the Docker image on port 8880:
(If you don't want to see the log of the run in the current window, replace `-it` with `-d`)

docker run -it --rm --name=rose_server -p 8880:8880 rose_server python ./rose-server

Open a browser at http://\<server-address\>:8880 to view and control the game.

## Running a driver

In a new window, open your virtual environment:
In a new window, open your virtual environment:

pipenv shell

Create your driver file:
Create your driver file:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundent space attheend of the line


cp examples/none.py mydriver.py

Edit the file mydriver.py and change the driver_name variable to your name.

Edit the file mydriver.py and change the driver_name variable to your name.

Start up the client, using your driver file:

Expand All @@ -115,13 +126,16 @@ The server address can be specified that way (Replace '10.20.30.44' with your se

./rose-client -s 10.20.30.44 mydriver.py

For running the driver on the Docker container use:

docker exec -it rose_server python ./rose-client examples/random-driver.py

For driver modules, see the [examples](examples) directory.

You can run the game with just 1 driver!
To let 2 drivers compete, repeat these commands in 2 terminals.

Command line interface
----------------------
## Command line interface

You can control the game from the command line using the rose-admin tool.

Expand All @@ -138,12 +152,10 @@ would change game rate to 10 frames per second:

./rose-admin <server-address> set-rate 10


## Creating a tarball

python setup.py sdist


## Developing

Should you want to contribute to the project, please read the [Code of Conduct](docs/code-of-conduct.md).
Expand All @@ -156,6 +168,10 @@ To open a shell for development, use:

pipenv --python /usr/local/bin/python3.7 shell

For development in docker, use:

docker build --build-arg DEV=True -t rose_dev .

Before submitting patches, please run the tests:

flake8
Expand Down