Skip to content

CMU-17-214/s24-lab13

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Lab 13

Changes compared to Lab 10

Instead of the development setup with the frontend on port 3000 and a proxy to the backend on port 8080, this implementation now runs the entire code from the backend on port 8080. Similar to HW5, the backend serves the compiled React code from the frontend at / and responds to API requests at /api addresses on the server.

This is done by App.java inherenting from SimpleWebServer rather than NanoHTTPD, where SimpleWebServer already implements how to serve static files from a directory (directory configured through the constructor call). We now overwrite the serve function to respond to the /api calls but delegate all other addresses to the superclass. The frontend code needs to be relative to the backend code at ../front-end/build.

The frontend is changed only minimally to expect the API at address /api.

Deployment as fat jar file

We use the maven-assembly-plugin plugin for maven to package the Java code with all dependencies into a single jar file when mvn package is called. The file can be found in target/back-end-1.0-SNAPSHOT-jar-with-dependencies.jar. With the extra declaration of the main class in the pom file configuration/archive/maifest/mainClass it is now possible to run the compiled Java code simply with java -jar target/back-end-1.0-SNAPSHOT-jar-with-dependencies.jar.

Building everything

Build the frontend and the backend, then package them with Docker.

cd back-end
mvn package
cd ../front-end
npm install
npm run build
cd ..
docker build -t lab13 --platform linux/amd64 .

You can run the container with docker run -p 8080:8080 lab13 and should be able to see the server starting on the command line and be able to access it at http://localhost:8080.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 48.6%
  • TypeScript 36.5%
  • HTML 7.5%
  • CSS 5.1%
  • Dockerfile 2.3%