Skip to content

cccp-education/edster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Edster Application

Edster is an application based on JHipster, designed to create and generate presentations. It leverages the JHipster platform to quickly develop and deploy modern presentation generating applications.

Generating the Codebase

The Edster codebase can be generated using the jdl.sh script. This script processes a JDL (JHipster Domain Language) file to define the application’s entities, relationships, and configurations.

Note: Before running the jdl.sh script for the first time, you need to make it executable using the following command:

chmod u+x scripts/jdl.sh

To generate the codebase:

  1. Execute the jdl.sh script:

    ./scripts/jdl.sh

This command will:

  • Parse the JDL file.

  • Generate the necessary application code based on the JDL definition.

Ensure that you have the necessary JHipster environment set up.

Cleaning the Generated Code

If you need to clean the generated code, you can use the clean.sh script.

Note: Before running the clean.sh script for the first time, you need to make it executable using the following command:

chmod u+x scripts/clean.sh

To clean the generated code:

  1. Execute the clean.sh script:

    ./scripts/clean.sh

This command will remove the generated code, allowing you to regenerate it using the jdl.sh script.

Development Mode

To run the application in development mode, use the following steps:

  1. Start the development environment:

    ./npmw run app:start;

This command will start the backend server with hot reloading enabled. The frontend is served by the webpack dev server.

  1. Access the application in your browser:

  2. Development-specific configurations:

    • Profile: dev

    • Hot reloading for backend changes

    • Webpack dev server for frontend

    • H2 database (if not configured differently)

Production Mode

To run the application in production mode, use the following steps:

  1. Build the production-ready package:

    ./gradlew -Pprod clean build

This command will:

  • Compile the Java code

  • Run tests

  • Package the application into a deployable archive (.war or .jar or .gradle )

  • Optimize the frontend assets

    1. Run the application:

      java -jar build/libs/edster-0.0.1.jar
Caution
The jar file name may vary depending on the version of the application.

This command will start the application using the production profile.

  1. Access the application in your browser:

  2. Production-specific configurations:

    • Profile: prod

    • Optimized and minified frontend assets

    • No hot reloading

    • Production database (e.g., PostgreSQL, MySQL)

Development Iteration

During development, you can run the backend and frontend separately for faster iteration.

  1. To run only the backend:

    ./npmw run backend:start;

This command will start the backend server on :

  1. To run the frontend in watch mode:

    ./npmw run start;

This command will start the frontend development server with hot reloading, allowing you to see changes in real-time on :

Synchronizing the Codebase

The sync.sh script helps synchronize manual code changes with the JDL-generated codebase. This ensures that customizations are preserved when regenerating the application using jdl.sh.

Note: Before running the sync.sh script for the first time, you need to make it executable using the following command:

chmod u+x scripts/sync.sh

To synchronize the codebase:

  1. Execute the sync.sh script:

    ./scripts/sync.sh

This script will identify and merge your manual changes into the newly generated code, minimizing conflicts and preserving your customizations.

Add an entry to .gitignore

Add the .goose folder to .gitignore

In order to add the .goose folder to .gitignore file, you must add this code at the end of the jdl.sh file

echo ".goose" >> .gitignore;

Running the Application front and back end separately in development mode on one terminal.

To run the application front and back end separately in development mode on one terminal, you can use the following steps:

./npmw run backend:start &;npm run start;

One ctrl+c will stop the front only. To stop backend, you will need to find the process id and kill it, like this :

killall -9 java

To re-run the front end :

npm run start;

Pushing Edster to Docker Hub

Generate a Docker Hub API Key

  • Create a Docker Hub account

  • Generate a key on Portainer or dockerhub.com

Deploying Docker Images to Docker Hub Programmatically

This document outlines the steps for programmatically deploying a Docker image to Docker Hub. We will use the docker-credential-helpers tool, specifically the pass credential helper, for secure storage of Docker Hub credentials.

Prerequisites

Ubuntu Prerequisites Installation

This section provides information specific to using pass as a credential store.

To use the pass credential helper, ensure that pass is installed and properly initialized:

  • Install pass: sudo apt-get install pass

  • Initialize pass with your GPG key ID: pass init <your_gpg_key_id>

Replace <your_gpg_key_id> with your actual GPG key ID.

  • Docker installed and running.

  • docker-credential-helpers installed. On Debian/Ubuntu: sudo apt-get install docker-credential-helper-pass

  • pass password manager installed and initialized. On Debian/Ubuntu: sudo apt-get install pass pass init <your_gpg_id> (replace <your_gpg_id> with your GPG key ID)

  • Docker Hub account and repository created.

Configuration

1. Configure docker-credential-helpers

Add pass to your ~/.docker/config.json file. If the credHelpers section doesn’t exist, create it.

Example ~/.docker/config.json
{
  "credsStore": "desktop",
  "credHelpers": {
    "docker.io": "pass"
  }
}
2. Store Docker Hub Credentials in pass

Use the pass command to store your Docker Hub username and personal access token (PAT). Important: Use a personal access token instead of your password for automated deployments. Generate a PAT on Docker Hub with "write" access to your repository.

pass insert docker-credential-helpers/docker.io

When prompted, enter your Docker Hub username and personal access token in the following format:

username=<your_dockerhub_username> password=<your_personal_access_token>

3. Login to Docker Hub

Log in to Docker Hub using the docker login command. docker-credential-pass will automatically retrieve the credentials from pass.

docker login

You should see "Login Succeeded" if the credentials were retrieved successfully.

Deployment Script Example

Here’s an example shell script to build, tag, and push a Docker image to Docker Hub:

Example deploy.sh
#!/bin/bash

# Set variables
IMAGE_NAME="your-image-name"
IMAGE_TAG="latest"
DOCKERHUB_USERNAME="your-dockerhub-username"
DOCKERHUB_REPO="your-dockerhub-repo"

# Build the Docker image
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} .

# Tag the image for Docker Hub
docker tag ${IMAGE_NAME}:${IMAGE_TAG} ${DOCKERHUB_USERNAME}/${DOCKERHUB_REPO}:${IMAGE_TAG}

# Push the image to Docker Hub
docker push ${DOCKERHUB_USERNAME}/${DOCKERHUB_REPO}:${IMAGE_TAG}

Important:

  • Replace your-image-name, latest, your-dockerhub-username, and your-dockerhub-repo with your actual values.

  • Make the script executable: chmod +x deploy.sh

Automation Notes

  • For CI/CD pipelines, ensure pass is available and initialized in the environment.

  • Consider using environment variables to pass sensitive information to the script, rather than hardcoding them.

  • Always use personal access tokens (PATs) instead of passwords for security.

  • Store the PAT securely (e.g., in a CI/CD secrets manager).

Verification

After the script runs successfully, verify that the image is pushed to your Docker Hub repository.

About

The communication tools platform.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published