Skip to content

Instructions

Cedric Wang edited this page Dec 5, 2023 · 24 revisions

Installation (Final Submission)

a) Installing the Client:

The final submission client installer is located in the releases directory under the name #TODO. To install the client, please choose the right installer for your system. (.dmg for Mac and .msi for Windows)

b) Installing the Server:

To run the client successfully, no installation of the server is needed as the server is located on Google Cloud Platform. The client application will automatically send requests to the cloud server. More specifically, we have a Cloud SQL instance running for our Postgres database, and we have two Cloud Run instances for our Ktor server and our Spring Boot server.

c) Building/Running the Project

To build/run our project for grading, here are the following instructions for our three main components

1) Client:

  • Packaging:

    To package the app, simply go to the Gradle menu on IntelliJ and go to the application folder and then the compose desktop folder in which you will find the command packageDmg (or for Windows packageMSI). This will create an installer on your local machine. The installer is usually installed in application/build/compose/binaries/main/dmg (or /msi).

Screen_Shot_2023-12-04_at_10.14.51_PM

  • Running locally

    To run the source code to create our client, simply navigate to the main.kt file and run the main function.

2) Ktor Server:

  • Building/Running:

    To run/build our ktor server to recreate a local instance of the server, there are three options depending on which is simplest for you:

  1. Pulling from Docker Hub and running the image

  2. Building the image from the Dockerfile yourself and running it.

  3. Combine the building and running with Docker Compose.

    Note that this local server will still connect to the Cloud for the database instance.

    Option 1: Docker Hub

    To pull our prebuilt image on Docker Hub, simply execute the following command on the terminal docker pull calendarapp346/calendar-app-ktor-cloud:tag1. After successfully pulling it, simply run the image with the following command: docker run -e GOOGLE_APPLICATION_CREDENTIALS=/app/calendarapp346-db9002f5232a.json -p 8080:8080 calendarapp346/calendar-app-ktor-cloud:tag1 .

    Option 2. Dockerfile To build the image yourself, you will first need to build the Fat Jar of the server. You can either go to the root of the project and do ./gradlew :server:buildFatJar or you can build it with the gradle menu on IntelliJ. It can be found in server/ktor/buildFatJar. Afterwards, navigate to the server directory and execute the following command: docker build -f Dockerfile . Note: the period is important in the command. Screen_Shot_2023-12-04_at_10.52.41_PM

    After the image has been built, you can run it with docker run -e GOOGLE_APPLICATION_CREDENTIALS=/app/calendarapp346-db9002f5232a.json -p 8080:8080 <image_name> where image_name is the name of the image you just built. You can see the image_name in Docker Desktop.

    Option 3. Docker Compose

    Docker Compose will automate the whole process of building and running it. Docker Compose should already be available with the installation of Docker Desktop. Once again, you will first need to build the Fat Jar of the server. You can either go to the root of the project and do ./gradlew :server:buildFatJar or you can build it with the gradle menu on IntelliJ. It can be found in server/ktor/buildFatJar. Afterwards, navigate to the server directory and execute docker compose up --build to up the server. After the building is done, the server will automatically be up just like the two previous options. Docker should know which file to build from, but if it fails you might need to specify the file docker-compose.yml.

3) Spring Boot Server:

Building/Running:

To run/build our Spring Boot server to recreate a local instance of the server, there are three options depending on which is simplest for you:

  1. Pulling from Docker Hub and running the image

  2. Building the image from the Dockerfile yourself and running it.

  3. Combine the building and running with Docker Compose.

    Option 1: Docker Hub

    To pull our prebuilt image on Docker Hub, simply execute the following command on the terminal docker pull calendarapp346/calendar-app-servers:tag1 After successfully pulling it, simply run the image with the following command: docker run -p 8081:8081 calendarapp346/calendar-app-servers:tag1

    Option 2. Dockerfile

    To build the image yourself, simply navigate to the plannerServer folder and execute the following command: docker build -f Dockerfile-planner . Note: the period is important in the command.

    The build might take some time, as it is taking care of building the Jar file as well. After the image has been built, you can run it with “docker run -p 8081:8081 <image_name>” where image_name is the name of the image you just built. You can see the image_name in Docker Desktop.

    Option 3. Docker Compose

    Docker Compose will automate the whole process of building and running it. Docker Compose should already be available with the installation of Docker Desktop. Simply navigate to the plannerServer directory and execute docker compose up --build to up the server. After the building is done, the server will automatically be up just like the two previous options.

d) Running the Tests:

Running the tests will take some extra work as they are set up to run on a local server due to us not wanting to send too many requests to the cloud and to not clutter our main database. We also want to use a local Postgres database instead of the Cloud one.

The installations are relatively simple. We have already set up Docker images to run that will create the local server and database for testing purposes.

  1. First pull the Postgres image by executing the command docker pull calendarapp346/calendar-app-postgres:tag1
  2. Now pull the local ktor image by executing the command docker pull calendarapp346/calendar-app-ktor-server:tag1
  3. Run the Postgres image with the command docker run -e POSTGRES_HOST_AUTH_METHOD=trust -e POSTGRES_DB=calendarApp -p 5432:5432 calendarapp346/calendar-app-postgres:tag1
  4. Run the ktor server image with the command docker run -p 8080:8080 calendarapp346/calendar-app-ktor-server:tag1 Note: You don't need to be in any specific directory to run any of the commands above. It is also important to run the Postgres image before the ktor image. The wrong order will result in the ktor server failing. Also make sure that the 8080 port in your local machine is not already occupied by other servers.

Now, you can run the tests. Navigate to the server/src/test/kotlin/com.example directory. You can running any of the tests or you can execute them all at the same time by right clicking the com.example directory on IntelliJ and clicking on Run 'Tests' in 'com.example' Screen_Shot_2023-12-05_at_6.17.59_PM

Clone this wiki locally