Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Backend-Docker/BooksPageable-0.0.4-SNAPSHOT.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions Backend-Docker/dockerfile.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM openjdk:21-jdk
MAINTAINER marc
COPY BooksPageable-0.0.4-SNAPSHOT.jar app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]

6 changes: 6 additions & 0 deletions FrontEnd-Docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM nginx:alpine

COPY frontend /usr/share/nginx/html
EXPOSE 80
CMD ["nginx","-g","daemon off;"]

149 changes: 149 additions & 0 deletions FrontEnd-Docker/frontend/assets/index-CO1OO85Z.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions FrontEnd-Docker/frontend/assets/index-kQJbKSsj.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions FrontEnd-Docker/frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React</title>
<script type="module" crossorigin src="/assets/index-CO1OO85Z.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-kQJbKSsj.css">
</head>
<body>
<div id="root"></div>
</body>
</html>
1 change: 1 addition & 0 deletions FrontEnd-Docker/frontend/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions Resources/Bash_scripts/qpubliLogFile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

# Get current date for log file name
log_date=$(date '+%Y-%m-%d')
log_file="log_${log_date}.txt"

# Function to log messages
log_message() {
local message="$(date '+%Y-%m-%d %H:%M:%S') - $1"
echo "$message" | tee -a "$log_file"
}

# Check if the commit message is provided
if [ -z "$1" ]; then
log_message "Error: Please provide a commit message."
exit 1
fi

# Start logging
log_message "Starting Quarto publishing process"

# Commit the changes with the provided message
git add .
git commit -m "$1"
if [ $? -eq 0 ]; then
log_message "Changes committed successfully"
else
log_message "Error: Git commit failed"
exit 1
fi

# Push the changes to the main branch
git push origin main
if [ $? -eq 0 ]; then
log_message "Changes pushed to remote repository"
else
log_message "Error: Git push failed"
exit 1
fi

# Publish to GitHub Pages using quarto
quarto publish gh-pages --no-render --no-prompt
if [ $? -eq 0 ]; then
log_message "Quarto site published successfully"
else
log_message "Error: Quarto publish failed"
exit 1
fi

log_message "Quarto publishing process completed successfully"

# Prompt user before exiting
while true; do
read -p "Do you want to exit the script? (y/n): " choice
case "$choice" in
y|Y )
log_message "Process completed. Check $log_file for details."
exit 0;;
n|N )
log_message "Continuing with the script..."
# You can add more actions here if needed.
break;;
* )
echo "Invalid input. Please enter 'y' or 'n'.";;
esac
done
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions Resources/Deploy-Spring-React/docker-push/docker-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
```bash
docker tag books-backend:latest w3564/books-backend:latest

docker push w3564/books-backend:latest
```
61 changes: 61 additions & 0 deletions Resources/Deploy-Spring-React/react-api-spring-deploy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Book Management Docker-standalone and Cloud Deployment

This project is a full-stack web application for managing books, consisting of a Spring Boot backend and a React frontend.

The components are containerized using Docker for local deployment and also deployed to cloud services for production use.

## Backend (Spring Boot)

- **Repository**: [BooksPageable](https://github.com/AlbertProfe/BooksPageable)

- **Description**: RESTful API for managing books

- **Key Features**: H2 In-Memory Database, RESTful API, CORS Configuration, Pagination Support

- **Build Tool**: Maven (IntelliJ IDEA)

- **Local Docker Deployment**:

```bash
docker run -d --name books-backend -p 8080:8080 books-backend-image
```

- **Cloud Deployment**:

- Dockerhub for image storage
- Render for hosting: [https://books-backend-icx2.onrender.com/api/books](https://books-backend-icx2.onrender.com/api/books)

## Frontend (React)

- **Repository**: [BooksFrontend](https://github.com/AlbertProfe/BooksFrontend)

- **Description**: User interface for book management

- **Key Features**: React UI, Axios Integration, CRUD Operations, Pagination Controls

- **Build Tool**: npm (Visual Studio Code)

- **Local Docker Deployment**:

```bash
docker run -d --name books-frontend -p 90:80 books-frontend-image
```

- **Cloud Deployment**:

- GitHub for source control
- AWS Amplify for hosting: [https://master.dfzntypm2yg8j.amplifyapp.com/](https://master.dfzntypm2yg8j.amplifyapp.com/)

## Cloud Deployment

1. **Backend (Spring Boot)**:

- Push Docker image to Dockerhub
- Deploy on Render: [https://books-backend-icx2.onrender.com/api/books](https://books-backend-icx2.onrender.com/api/books)

2. **Frontend (React)**:

- Push code to GitHub
- Deploy on AWS Amplify: [https://master.dfzntypm2yg8j.amplifyapp.com/](https://master.dfzntypm2yg8j.amplifyapp.com/)

This setup allows for both local development using Docker and production deployment using cloud services, providing flexibility and scalability for the Book Management application.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions Resources/Docker_commands/docker-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@


# docker run

```bash
docker run -d -p 8080:8080 -p 50000:50000
-v jenkins_home:/var/jenkins_home
-v /var/run/docker.sock:/var/run/docker.sock
--name jenkins
jenkins/jenkins:lts
```



This command creates and runs a new Jenkins container:

- `-d`: Runs the container in detached mode (in the background)
- `-p 8080:8080`: Maps port 8080 from the container to port 8080 on the host
- `-p 50000:50000`: Maps port 50000 from the container to port 50000 on the host
- `-v jenkins_home:/var/jenkins_home`: Creates a volume named jenkins_home and mounts it to /var/jenkins_home in the container
- `-v /var/run/docker.sock:/var/run/docker.sock`: Mounts the Docker socket from the host to the container
- `--name jenkins`: Names the container "jenkins"
- `jenkins/jenkins:lts`: Specifies the Jenkins LTS image to use
129 changes: 129 additions & 0 deletions Resources/Docker_commands/docker-states.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Docker Images and Containers

### Image

An image is a read-only template containing instructions for creating a Docker container: <mark>it's like a snapshot of a container.</mark>

Example:

```bash
jenkins/jenkins:lts
```

## Container

A container is a runnable instance of an image. It's a lightweight, standalone, executable package that includes everything needed to run an application.

Example:

```bash
docker run -d -p 8080:8080 -p 50000:50000 \
-v jenkins_home:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
--name jenkins \
jenkins/jenkins:lts
```

<img src="https://miro.medium.com/v2/resize:fit:331/1*rCo_Q1-f7V5zYoKAQed_Mw.png" title="" alt="" data-align="center">

## Container States

1. **Created**: Container is created but not started.
2. **Running**: Container is actively executing processes.
3. **Paused**: Container processes are temporarily stopped.
4. **Exited**: Container has completed its execution or was stopped.
5. **Dead**: Container failed to start or be removed completely.

## Docker Commands and Container States

### docker run

Creates and starts a new container instance.

```bash
docker run -d --name jenkins jenkins/jenkins:lts
```

State Transition: Created → Running

## docker pause

Suspends all processes in the specified containers.

```bash
`docker pause jenkins`
```

State: Running → Paused

*Key Differences*

- `docker start`: Restarts a stopped container, resuming processes.
- `docker pause`: Suspends processes in a running container without termination.



### docker stop

Stops a running container.

```bash
docker stop jenkins
```

State Transition: Running → Exited

### docker start

Restarts an existing stopped container.

```bash
docker start jenkins
```

State Transition: Exited → Running

*Key Differenced*

- `docker start`: Restarts an existing stopped container.
- `docker run`: Creates a new container instance.

## Docker Stop vs Docker Kill

The main difference between `docker stop` and `docker kill` lies in how they terminate containers:

**Docker Stop**

- Sends a SIGTERM signal first, allowing for graceful shutdown

- Gives the container a chance to clean up and save data

- Has a default timeout of 10 seconds before forcefully terminating

- Preferred for normal container shutdown

**Docker Kill**

- Sends a SIGKILL signal immediately

- Forcefully terminates the container without allowing cleanup

- Used when containers are unresponsive or need immediate termination

*When to Use*

- **Docker Stop**: Use for normal container shutdown to allow proper cleanup and data saving

- **Docker Kill**: Use when containers are locked up or not responding to stop commands

It's generally recommended to use `docker stop` first, and only resort to `docker kill` if the container doesn't respond or you need immediate termination[

### Key Differences: Docker Stop vs Docker Kill

| Aspect | Docker Stop | Docker Kill |
| ------------------- | --------------------- | ----------------------- |
| Signal | SIGTERM, then SIGKILL | SIGKILL |
| Graceful Shutdown | Yes | No |
| Cleanup Opportunity | Yes | No |
| Speed | Slower (up to 10s) | Immediate |
| Use Case | Normal shutdown | Unresponsive containers |
11 changes: 11 additions & 0 deletions Resources/Dockerfiles/app.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
docker# Use a Java 17 base image
FROM openjdk:17-jdk-slim

# Maintainer information
MAINTAINER albertprofe

# Copy the application JAR file to the container
COPY restaurant-0.0.1-SNAPSHOT.jar restVaadin.jar

# Set the entry point to run the JAR file
ENTRYPOINT ["java", "-jar", "restVaadin.jar"]
14 changes: 14 additions & 0 deletions Resources/Dockerfiles/app3.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Use an official lightweight Nginx image
FROM nginx:alpine

# Set the working directory to /usr/share/nginx/html
WORKDIR /usr/share/nginx/html

# Copy the static files from the dist directory to the container
COPY books-frontend/dist .

# Expose port 80 for the web server
EXPOSE 80

# Command to run when the container starts
CMD ["nginx", "-g", "daemon off;"]
22 changes: 22 additions & 0 deletions Resources/Dockerfiles/app4.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Importing JDK and copying required files
FROM openjdk:19-jdk AS build
WORKDIR /app
COPY pom.xml .
COPY src src

# Copy Maven wrapper
COPY mvnw .
COPY .mvn .mvn

# Set execution permission for the Maven wrapper
RUN chmod +x ./mvnw
RUN ./mvnw clean package -DskipTests

# Stage 2: Create the final Docker image using OpenJDK 19
FROM openjdk:19-jdk
VOLUME /tmp

# Copy the JAR from the build stage
COPY --from=build /app/target/*.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
EXPOSE 8080
Loading