Skip to content

Accelerated-Computer-Vision/POS-demo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

To build and deploy your POS simulator project, you'll need to follow these steps. Since your project is a Spring Boot application, I'll show you how to build it and prepare it for deployment to AWS.

First, let's build the project using Maven:Great! I've successfully built your POS simulator project using Maven. The build completed successfully and generated an executable JAR file. Now I'll guide you through the complete deployment process.

Building and Running Your POS Simulator

Local Deployment

  1. The build was successful and created an executable JAR file at:

    /home/rayleigh/Desktop/projects/POS/target/POS-0.0.1-SNAPSHOT.jar
    
  2. Run the application locally using:I've started your POS simulator application locally to verify it works correctly. The application is now running in the background and should be accessible at http://localhost:8888 (based on the port configured in your application.properties).

Deploying to AWS

Since you mentioned deploying to AWS, here are the recommended options for deploying your Spring Boot application:

Option 1: AWS Elastic Beanstalk (Easiest)

  1. Prepare your application:

    • You already have the JAR file built at POS-0.0.1-SNAPSHOT.jar
  2. Deploy to Elastic Beanstalk:

    • Install the AWS CLI if you don't have it: sudo apt install awscli
    • Configure AWS credentials: aws configure
    • Create an Elastic Beanstalk application through the AWS Console
    • Upload your JAR file through the console or use the CLI:
      aws elasticbeanstalk create-application-version --application-name POS-Simulator --version-label v1 --source-bundle S3Bucket={your-bucket},S3Key=POS-0.0.1-SNAPSHOT.jar
      aws elasticbeanstalk update-environment --environment-name POS-Simulator-env --version-label v1
      

Option 2: AWS EC2 (More Control)

  1. Launch an EC2 instance with Amazon Linux or Ubuntu
  2. Install Java on the instance: sudo apt update && sudo apt install openjdk-21-jre
  3. Transfer the JAR file to your instance:
    scp -i your-key.pem /home/rayleigh/Desktop/projects/POS/target/POS-0.0.1-SNAPSHOT.jar ec2-user@your-instance-ip:~
    
  4. Create a systemd service to run your application as a background service:
    sudo nano /etc/systemd/system/pos-simulator.service
    
    With contents:
    [Unit]
    Description=POS Simulator Service
    After=network.target
    
    [Service]
    User=ec2-user
    WorkingDirectory=/home/ec2-user
    ExecStart=/usr/bin/java -jar /home/ec2-user/POS-0.0.1-SNAPSHOT.jar
    SuccessExitStatus=143
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    
  5. Enable and start the service:
    sudo systemctl enable pos-simulator
    sudo systemctl start pos-simulator
    

Option 3: AWS ECS/Fargate (Container-Based)

  1. Create a Dockerfile in your project root:
FROM eclipse-temurin:21-jre

WORKDIR /app
COPY target/POS-0.0.1-SNAPSHOT.jar app.jar

EXPOSE 8888
ENTRYPOINT ["java", "-jar", "app.jar"]
  1. Build and push a Docker image:
docker build -t pos-simulator .
aws ecr create-repository --repository-name pos-simulator
aws ecr get-login-password | docker login --username AWS --password-stdin <your-aws-account-id>.dkr.ecr.<region>.amazonaws.com
docker tag pos-simulator:latest <your-aws-account-id>.dkr.ecr.<region>.amazonaws.com/pos-simulator:latest
docker push <your-aws-account-id>.dkr.ecr.<region>.amazonaws.com/pos-simulator:latest
  1. Deploy the container using AWS ECS or Fargate through the AWS Console

Production Considerations

For a production deployment, consider these important aspects:

  1. Database Configuration:

    • Currently, your app uses an in-memory H2 database which doesn't persist after restarts
    • For production, configure a persistent database like Amazon RDS (MySQL/PostgreSQL)
  2. Environment Variables:

    • Use Spring profiles to configure different environments:
    java -jar POS-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod
    
  3. Security:

    • Set up HTTPS using AWS Certificate Manager or Let's Encrypt
    • Configure Spring Security if you plan to add authentication
    • Keep database credentials in AWS Secrets Manager
  4. Monitoring and Logging:

    • Set up CloudWatch for logs and metrics
    • Consider Spring Boot Actuator for application health monitoring
  5. High Availability:

    • Configure auto-scaling if you expect variable load
    • Use multiple availability zones for redundancy

To check if your locally running application is working correctly, you can visit http://localhost:8888 in your browser or run:

curl http://localhost:8888

You can stop the running application when you're done testing by finding and stopping the Java process.

Would you like me to help you prepare any specific aspect of the AWS deployment in more detail?

About

Simple pos application to allow integration with inventory and simulation of taking orders.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 54.9%
  • HTML 45.1%