Giter VIP home page Giter VIP logo

f23-rec12-fixed's Introduction

Lab 12

Changes compared to Lab 7

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 lab12 --platform linux/amd64 .

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

f23-rec12-fixed's People

Contributors

jlacomis avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.