From 3a1450dade275cdbbdd94cf69e4b6cbe2873c88c Mon Sep 17 00:00:00 2001 From: Marvin Scham Date: Sat, 24 Jun 2023 23:34:13 +0000 Subject: [PATCH] Docker/-compose --- CHANGELOG.md | 1 + Dockerfile | 28 ++++++++++++++++++++++++++++ README.md | 33 ++++++++++++++++++++------------- Script/Bump_Version.sh | 23 +++++++++++++++++++++++ Script/SonarQube_Local.sh | 5 ++--- docker-compose.yml | 11 +++++++++++ pom.xml | 21 +++++++++++++++++++++ 7 files changed, 106 insertions(+), 16 deletions(-) create mode 100644 Dockerfile create mode 100644 Script/Bump_Version.sh create mode 100644 docker-compose.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index a8f50bb..9ef2078 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - `AmazonPurchaser` - `EbaySeller` - `EbayPurchaser` +- Dockerfile and `docker-compose.yml` ## 0.2.0 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3939c20 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +# Use the official maven/Java 17 image to create a build artifact. +# https://hub.docker.com/_/maven +FROM maven:3.9.1-eclipse-temurin-17 AS build + +# Set the working directory in the image to /app +WORKDIR /app + +# Copy the pom.xml file into the current directory (/app) in the image +COPY pom.xml . + +# Download all required dependencies into one layer +RUN mvn -B dependency:go-offline + +# Copy the rest of the application source code +COPY src /app/src + +# Build the application +RUN mvn -B package -DskipTests + +# Use OpenJDK 17 for the runtime stage of the Dockerfile +FROM openjdk:17-jdk-slim + +# Copy the jar file from the build stage +COPY --from=build /app/target/easydrop-0.3.0-SNAPSHOT.jar /easydrop.jar + +# Execute the application when the docker container starts. +ENTRYPOINT ["java", "-jar", "/easydrop.jar"] + diff --git a/README.md b/README.md index e465e36..e4827d7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # EasyDrop -![Version](https://img.shields.io/badge/version-0.3.0_SNAPSHOT-orange) +![Version](https://img.shields.io/badge/version-0.3.0–SNAPSHOT-orange) ![Pipeline](https://gitlab.fbe-adswen.rwu.de/team1/sandbox2/badges/main/pipeline.svg) [![Coverage](https://sonar.fbe-adswen.rwu.de/api/project_badges/measure?project=de.rwu%3Aeasydrop&metric=coverage&token=sqb_2fe80aed361468170aaef32a0ff96d596456cdd1)](https://sonar.fbe-adswen.rwu.de/dashboard?id=de.rwu%3Aeasydrop) ![JAMANN](https://img.shields.io/badge/Auszahlung-Letzte%20Woche-brightgreen) @@ -13,30 +13,37 @@ Get rich quick™ with fully automated dropshipping! ![Demo Image](Docs/DemoImage.png) -## Installation ⚙ +## Installation/Usage ⚙ -As the application is still in development, development software will be required along its regular execution environment. - -- JDK 17 -- Maven -- _[More/context](https://gitlab.fbe-adswen.rwu.de/team1/sandbox2/-/wikis/Projektdokumentation/Development#software)_ - -## Usage 🛠 +- Install Docker + Compose +- Clone this repository Set up the required configuration files, use the corresponding demo files for orientation. - `config/config.properties` for API authorization - `products-config.json` to define product catalogues to use for dropshipping -Run the following command to execute the program: +Create the container -```sh -mvn compile exec:java -Dexec.mainClass="de.rwu.easydrop.Main" +```bash +docker-compose build +``` + +Then run it! + +```bash +docker-compose up +``` + +To run it on a fixed schedule, install a cron job, e.g. + +```bash +*/30 * * * * cd /home/user/easydrop && docker-compose up -d ``` ## Roadmap 🏁 -_Future ideas!_ +- Access transaction log ## Contributing 👷‍♂️👷‍♀️ diff --git a/Script/Bump_Version.sh b/Script/Bump_Version.sh new file mode 100644 index 0000000..190506d --- /dev/null +++ b/Script/Bump_Version.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Checking if correct number of arguments are provided +if [ "$#" -ne 2 ]; then + echo "Required CLI args missing: [old_version, new_version]" + exit 1 +fi + +# Assigning command line arguments to variables +old_version="$1" +new_version="$2" + +old_version_alt=${old_version//-/–} +new_version_alt=${new_version//-/–} + +# Replacing old_version with new_version in README.md +sed -i "s/version-$old_version_alt-orange/version-$new_version_alt-orange/g" README.md +sed -i "s/$old_version/$new_version/g" pom.xml +sed -i "s/easydrop-$old_version.jar/easydrop-$new_version.jar/g" Dockerfile +sed -i "s/image: easydrop:$old_version/image: easydrop:$new_version/g" docker-compose.yml + +echo "Version number updated successfully" + diff --git a/Script/SonarQube_Local.sh b/Script/SonarQube_Local.sh index 14d2602..8517553 100644 --- a/Script/SonarQube_Local.sh +++ b/Script/SonarQube_Local.sh @@ -2,6 +2,5 @@ mvn clean verify sonar:sonar -Pcoverage \ -Dsonar.projectKey=EasyDrop \ -Dsonar.projectName='EasyDrop' \ -Dsonar.host.url=http://localhost:9000 \ - -Dsonar.token=sqp_82d35689c620c15fd1064549375e17a2a5b0b931 - -start http://localhost:9000/dashboard?id=EasyDrop \ No newline at end of file + -Dsonar.token=sqp_82d35689c620c15fd1064549375e17a2a5b0b931 \ +&& start http://localhost:9000/dashboard?id=EasyDrop \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..fe6a261 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: "3.8" + +services: + easydrop: + container_name: easydrop + build: + context: . + dockerfile: Dockerfile + image: easydrop:0.3.0-SNAPSHOT + volumes: + - ./config:/config diff --git a/pom.xml b/pom.xml index 587ec28..6d1d8ff 100644 --- a/pom.xml +++ b/pom.xml @@ -86,6 +86,27 @@ + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + + + de.rwu.easydrop.Main + + + + + + org.apache.maven.plugins maven-checkstyle-plugin