Giter Club home page Giter Club logo

java-mysql-rest-api's Introduction

Topcoder Java API With MySQL Starter Pack:

Requirements:

  • Docker 17.05+
  • Docker-Compose

Configuration:

  • The application configuration can be found at src/main/resources/application.properties

  • For running the application on Docker using the provided docker-compose, use the default configuration provided.

  • The following configuration parameters are defined:

    • spring.datasource.url The database url, can be overwritten by the environment variable DATABASE_URL.
    • spring.datasource.username The database username, can be overwritten by the envrionment variable DATABASE_USERNAME.
    • spring.datasource.password The database password, can be overwritten by th environment variable DATABASE_PASSWORD.
    • spring.jpa.properties.hibernate.dialect The database dialect, it should be a dialect supported by the user version of MySQL, the default value is org.hibernate.dialect.MySQL8Dialect
    • spring.jpa.show-sql The flag indicating whether to show the SQL statement generated by hibernate in logs, by default it is set to true, It should be set to false on production, it can be overwritten by the environment variable SHOW_SQL.
    • logging.level.root The root logging level, default value is 'info', it can be overwritten by the environment variable ROOT_LOGGING_LEVEL.
    • logging.level.com.topcoder.api The api logging level, default value is 'info', it can be overwritten by the environment variable API_LOGGING_LEVEL.
    • logging.file The logging file name, default value is server.log and can be overwritten by the environment variable LOG_FILE.
    • logging.file.max-size The logging file maximim size, default value is 50MB and can be overwritten by the environment variable LOG_FILE_MAX_SIZE.
    • server.port The port number on which the API will be listening, default value is 8080, it can be overwritten by the environment variable SERVER_PORT.
    • server.servlet.context-path The API prefix, default value is '/api/v1', it can overwritten by the environment variable API_PREFIX.
  • In docker-compose.yml, the following environment variables are used:

    • DATABASE_NAME: The database name, the default value is 'topcoder'.
    • DATABASE_USERNAME: The database username, the default value is 'topcoder'.
    • DATABASE_PASSWORD: The database password, the default value is 'Topcoder123'.
    • DATABASE_ROOT_PASSWORD: The MySQL root password, the default value is 'Topcoder123'

When running the MySQL db container, a database with the configured name (default to 'topcoder') will be created. A database user and password will also be created using the configured environment variables or default values 'topcoder/Topcoder123'.

Deployment on docker:

  • Keep the default provided configuration.
  • Navigate to the application root folder (java-mysql) where docker-compose.yml resides and run the following command:
docker-compose up

This will start mysql database and the API containers, the API will be listening on port 8080.

Local Deployment:

  • Start MySQL database using the provided docker-compose.yml by running docker-compose up mysql-db
  • Configure the application as described above by updating src/main/resources/application.properties or by using environment variables.
  • If the provided docker-compose.yml is used for starting the database, we only need to update DATABASE_URL value (The database and users table will be created automatically): export DATABASE_URL="jdbc:mysql://<Docker-IP>:3306/topcoder" (replace with the IP address of docker machine)
  • Run the API by executing the following command : mvn spring-boot:run

Verification:

Refer to Validation.md

java-mysql-rest-api's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.