Coursework 1
Branch | For Courseworks 1 and 2 | (check the branch list for available templates)
This repo is a good template if you want to run your RMI work using Docker. This would mean that you do not need to install Java on computer to build/run your code and the RMI registry.
In here is just the calculator example that can be found on Moodle.
Tested on Docker for Mac and Linux and Windows 10
- Docker Engine
- Docker CLI
- Docker Compose
- Clone me from this git repo:
git clone https://github.com/scc311/rmi-docker-template -b cw1 rmi-cw
- Change to the cloned root directory:
cd rmi-cw
(this should put you in the same directory as this README) - Make sure your client code is in the
client-code
directory. - Update the
client-code/entrypoint.sh
's java command to the file with the name of the file with yourmain
in it.- (without the .java extension)
- Any reference to
localhost
in your client (specifically your rmi lookup), needs to be replaced withDockerUtility.getRegistryHost()
. - Make sure your server code is in the
server-code
directory. - Update the
server-code/entrypoint.sh
's java command to the file with the name of the file with yourmain
in it.- (without the .java extension)
- Make sure your interface code is in the
interface-code
directory. - From the root directory of those 3 folders (the one with this README in)
1. To build your code (or re-build after you make changes), run:
docker-compose build
2. To run the registry, server, and client, run:docker-compose up
3. UseCtrl-C
to get out of the container's tty.
⚠️ The container images will contain your coursework! DO NOT push the built images to a public container registry!
🚨 Life is easier with compose, so you don't really need this...
- Much like in the steps above, make sure you code is divided up and in the correct directories. These steps just replace step 9.
- All command below should be run from the root directory.
- If you can, use
tmux
or different terminal windows for the client and server.
- From the root directory (with the README in), run the following to build the container image (and your server code):
docker build --rm -f server-code/Dockerfile -t rmi-server .
- Next, to run your server (and simultaneously start the registry), run:
docker run --rm -it --network host --privileged rmi-server
- From the root directory (with the README in), run the following to build the container image (and your client code):
docker build --rm -f client-code/Dockerfile -t rmi-client .
- Next, to run your client, run:
docker run --rm -it --network host --privileged rmi-client