diff --git a/Dockerfile b/Dockerfile index e3b4059..aa9241c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,13 @@ # syntax=docker/dockerfile:1 # Build and Run docker image with --tag e.g. "wedemyserver" -FROM maven:3-eclipse-temurin-alpine AS build +FROM maven:3-eclipse-temurin-17-alpine AS build WORKDIR /app COPY pom.xml ./ COPY src ./src RUN mvn clean -DskipTests package -FROM eclipse-temurin:jre-alpine AS runner +FROM eclipse-temurin:17-jre-alpine AS runner WORKDIR /app COPY --from=build /app/target/wedemyserver.jar /app EXPOSE 9000 diff --git a/README.md b/README.md index 2feee5c..963cc44 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # WedemyServer -[![Static Badge](https://img.shields.io/badge/API_docs-v1.2-red)](https://longwater1234.github.io/WedemyServer/) +[![Static Badge](https://img.shields.io/badge/API_docs-v2.0-red)](https://longwater1234.github.io/WedemyServer/) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/Longwater1234/WedemyServer/graphs/commit-activity) [![License: MIT](https://img.shields.io/github/license/Longwater1234/WedemyServer)](https://github.com/Longwater1234/WedemyServer/blob/master/LICENSE) [![Static Badge](https://img.shields.io/badge/reference-help.md-orange)](HELP.md) -(Backend repo). Clone of Udemy, an e-learning platform, built using SpringBoot + Vue 3 + Typescript. With CreditCard and +(Backend repo). Clone of Udemy, an e-learning platform, built using SpringBoot 3 + Vue 3 + Typescript. With CreditCard and PayPal checkout (both powered by **Braintree Payments**). Uses Spring Security & Spring Session Redis (via cookies[^1] or sessionID Headers) for auth, instead of stateless JWT Tokens. CSRF protection is enabled. You can easily customize these settings in [SecurityConfig](src/main/java/com/davistiba/wedemyserver/config/SecurityConfig.java). By default, the @@ -14,13 +14,13 @@ app runs on port 9000. ## Frontend & Live Demo Click to view [Frontend Repo](https://github.com/Longwater1234/WedemyClient) and live Demo built using Vue 3, Vite and -Typescript. However, you can still use any frontend stack with this project. See -the [API Docs](https://longwater1234.github.io/WedemyServer/) for this project. +Typescript. However, you may use any other frontend stack with this project. See +the [OpenAPI Docs](https://longwater1234.github.io/WedemyServer/) for this project. -## Requirements +## Minimum Requirements -- JDK 11 or newer -- MySQL 8.0 or newer (NOT compatible with MariaDB) +- Java 17 or newer +- MySQL 8.0.x or newer - Redis Server (latest stable) - [Google OAuth Credentials](https://developers.google.com/identity/gsi/web/guides/get-google-api-clientid) (for Google Login) @@ -32,7 +32,7 @@ the [API Docs](https://longwater1234.github.io/WedemyServer/) for this project. You MUST set these variables on your Local or Cloud ENV before you launch this SpringBoot app. **πŸ’‘TIP**: During dev/test, you can pass them via `args`, OR store inside your IDE: e.g. In either Eclipse or IntelliJ IDE, in the top toolbar, find the **"Run"** menu > **Edit/Run Configuration** > **Environment** > **Environmental Variables**. Add (+) -each key and its value, then click **Apply**. If using Docker CLI, follow this quick +each key and its value, then click **Apply**. If using Docker CLI, please follow this quick [official guide.](https://docs.docker.com/engine/reference/commandline/run/#env) ```properties @@ -61,7 +61,8 @@ in [BraintreeConfig](src/main/java/com/davistiba/wedemyserver/config/BraintreeCo ## Database Setup Using any MySQL client, CREATE new database called `wedemy` (any name is OK), with charset `utf8mb4`. Then follow -carefully the rest of instructions in [HELP.md](HELP.md#database-setup-info), for both MySQL and Redis. +carefully instructions in [HELP.md](HELP.md#database-setup-info), for both MySQL and Redis. We recommend NOT to use +`root` account in prod for Db; create new user account with fewer privileges. ## Quick Start πŸš€ @@ -77,21 +78,22 @@ java -jar target/wedemyserver.jar ### With Docker -I have attached [Dockerfile](Dockerfile) for the Spring server only. You will need to set up MySQL & Redis -separately. Refer to official Docker docs on how to pass Env variables. +I have attached [Dockerfile](Dockerfile) for the Springboot server only. You will need to set up MySQL & +Redis separately. Refer to official Docker docs on how to pass ENV variables listed above. ```bash - docker build -t wedemy-server . - docker run --name "wedemy" -d -p9000:9000 wedemy-server + docker build -t wedemyserver . + docker run --name "wedemy" -d -p9000:9000 wedemyserver ``` -TipπŸ’‘ : If using Docker Desktop (latest), before starting container, you can fill in the ENV vars in the GUI directly. +**Tip** πŸ’‘ : If using Docker Desktop (latest), before starting container, you can fill in the ENV vars in the GUI +directly. See [screenshot](src/main/resources/docker_env.PNG) ## Deploying your App 🌍 This App can be easily deployed within few minutes, straight from GitHub to your Cloud PaaS of choice. You can either -use the [Dockerfile](Dockerfile) provided, or as a pure Java app. Popular PaaS with CI/CD for Java +use the [Dockerfile](Dockerfile) provided, or as a pure Java app. Popular PaaS with CI/CD for Java (without Dockerfile) include: Heroku, AWS ElasticBeanstalk, Google App Engine, Azure Web Apps. The following may **require** a Dockerfile: Dokku, Railway, Render.com, Fly.io. Please note, you will also need a **separate** MySQL & Redis instance! diff --git a/pom.xml b/pom.xml index 12512ce..70d217c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,25 +6,25 @@ org.springframework.boot spring-boot-starter-parent - 2.7.18 + 3.4.0 com.davistiba wedemyserver - 1.2 + 2.0.0 wedemyserver Wedemy clone server, built with Spring Boot https://github.com/longwater1234/WedemyServer - 11 - 11 - 11 + 17 + 17 + 17 - javax.validation - validation-api + jakarta.validation + jakarta.validation-api org.hibernate.validator @@ -136,6 +136,11 @@ braintree-java 3.37.0 + + org.springframework.boot + spring-boot-properties-migrator + runtime +