GitHub Repository for CSUnplugged Project
This project repository contains the source code and design artifacts for CS-Unplugged Activity, Peruvian Flip Coin.
The folder "Greenfoot" contains the GreenFoot client and "src" contains the code for Restlet based game Server.
Deploy the Game in two parts : 1) Deploying Server and 2) Configuring Client.
- Deploying the Server. ================
- compile all the java files providing the jar dependencies from "src/Dist".
javac -cp dist\json.jar;dist\restlet.jar;dist\restlet-json.jar -d build src\Peruvian*.java src\api*.java
-
Switch to directory "build" cd build
-
Create Executable jar for the server compiled code.
jar -cvfe ..\dist\app.jar PeruvianServer .
- To test on a localhost, change to parent directory and run the server
cd ..
java -cp build;dist\restlet.jar;dist\restlet-json.jar;dist\json.jar api.PeruvianServer
Once successfully tested on localhost, dockerize the server app.
- Create the docker configuration file.
FROM openjdk EXPOSE 8080 ADD ./dist/app.jar /srv/app.jar ADD ./dist/restlet.jar /srv/restlet.jar ADD ./dist/restlet-json.jar /srv/restlet-json.jar ADD ./dist/json.jar /srv/json.jar CMD java -cp build:/srv/restlet.jar:/srv/restlet-json.jar:/srv/json.jar:/srv/app.jar api.Peruvian
- Open the docker quick start terminal.
a)docker login -u
b)docker build -t peruvianServer .
c)docker push /gumball
-
Log in to docker cloud, fetch the repo from docker hub.
-
Create a new service and expose it on port 80.
-
Note the docker container URL.
-
Test the url by getting game status : url/Peru
=============================================================
- Configuring the Greenfoot Client ===============================================
-
Open the project.greenfoot file.
-
Open the driver Actor.
-
Replace the restAPI url with the one noted in Step 10. for server configuration.
-
Restart JVM
-
Start the game. Note the game key and communicate to Player 2.
-
Enjoy :)