-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from abdelaziz-mahdy/spring-boot
Spring boot
- Loading branch information
Showing
38 changed files
with
3,211 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
services: | ||
db: | ||
image: postgres:16.1 | ||
restart: always | ||
# volumes: | ||
# # - ./data/db:/var/lib/postgresql/data | ||
# # - ./pg_hba.conf:/var/lib/foo/pg_hba.conf | ||
# command: postgres -c hba_file=/var/lib/foo/pg_hba.conf | ||
environment: | ||
- POSTGRES_DB=postgres | ||
- POSTGRES_USER=postgres | ||
- POSTGRES_PASSWORD=postgres | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U postgres"] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 5 | ||
|
||
# pgbouncer: | ||
# image: edoburu/pgbouncer | ||
# environment: | ||
# - DB_USER=postgres | ||
# - DB_PASSWORD=postgres | ||
# - DB_HOST=db | ||
# # - DB_NAME=test | ||
# - POOL_MODE=transaction | ||
# - ADMIN_USERS=postgres,dbuser | ||
# - AUTH_TYPE=scram-sha-256 | ||
# - MAX_CLIENT_CONN=100000 | ||
# # ports: | ||
# # - "5432:5432" | ||
# depends_on: | ||
# - db | ||
# healthcheck: | ||
# test: "pg_isready --host localhost -U postgres" | ||
# interval: 5s | ||
# timeout: 5s | ||
# retries: 5 | ||
benchmark: | ||
restart: always | ||
build: | ||
context: ./server | ||
dockerfile: ./Dockerfile | ||
|
||
ports: | ||
- "${PORT:-8080}:8080" | ||
|
||
environment: | ||
- DATABASE_NAME=postgres | ||
- DATABASE_USER=postgres | ||
- DATABASE_PASSWORD=postgres | ||
- DATABASE_HOST=db | ||
- DATABASE_PORT=5432 | ||
healthcheck: | ||
test: "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null http://127.0.0.1:8080/" | ||
start_period: 30s | ||
interval: 15s | ||
timeout: 10s | ||
retries: 10 | ||
depends_on: | ||
# pgbouncer: | ||
# condition: service_healthy | ||
db: | ||
condition: service_healthy | ||
tester: | ||
image: locustio/locust | ||
volumes: | ||
- ./tests:/mnt/locust | ||
- ./tests/results/${test_type}:/home/locust/ | ||
command: > | ||
-f /mnt/locust/${test_type}.py | ||
--csv benchmark | ||
--run-time ${LOCUST_RUNTIME} | ||
--headless | ||
--users ${LOCUST_USERS} | ||
--spawn-rate ${LOCUST_SPAWN_RATE} | ||
-H http://benchmark:8080 | ||
${LOCUST_ARGS} | ||
--master | ||
# ports: | ||
# - 8089:8089 | ||
depends_on: | ||
benchmark: | ||
condition: service_healthy | ||
tester_worker: | ||
image: locustio/locust | ||
volumes: | ||
- ./tests:/mnt/locust | ||
- ./tests/results/${test_type}:/home/locust/ | ||
command: > | ||
-f /mnt/locust/${test_type}.py | ||
--worker --master-host tester | ||
depends_on: | ||
benchmark: | ||
condition: service_healthy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
cd "${0%/*}" | ||
|
||
# Build and start services for Django-Python | ||
# cd benchmark | ||
# bash update_requirements.sh | ||
# cd .. | ||
|
||
#!/bin/bash | ||
|
||
# Save the current directory | ||
dir=$(pwd) | ||
|
||
# Flag to check if the script is found | ||
found=0 | ||
|
||
# Loop through the current and parent directories | ||
while true; do | ||
# Check if the script exists in the current directory | ||
if [[ -f "$dir/internal_scripts/set_required_envs.sh" ]]; then | ||
# Script found, execute it | ||
echo "Found script at $dir/internal_scripts/set_required_envs.sh" | ||
. "$dir/internal_scripts/set_required_envs.sh" | ||
|
||
found=1 | ||
break | ||
else | ||
# Move to the parent directory | ||
parentdir=$(dirname "$dir") | ||
# Check if we have reached the root directory | ||
if [[ "$dir" == "$parentdir" ]]; then | ||
break | ||
fi | ||
dir=$parentdir | ||
fi | ||
done | ||
|
||
# Check if script was not found | ||
if [[ $found -eq 0 ]]; then | ||
echo "Script not found." | ||
exit 1 | ||
fi | ||
|
||
. "$dir/internal_scripts/set_test_type.sh" | ||
|
||
# Rest of the script... | ||
. "$dir/internal_scripts/record_usages.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Use the official Maven image to build the app | ||
FROM maven:3.8.1-openjdk-17 AS build | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy the pom.xml and download dependencies | ||
COPY pom.xml . | ||
RUN mvn dependency:go-offline -B | ||
|
||
# Copy the source code | ||
COPY src ./src | ||
|
||
# Package the application | ||
RUN mvn package -DskipTests | ||
|
||
# Use the official OpenJDK image to run the app | ||
FROM openjdk:17-jdk-slim | ||
|
||
# Install curl | ||
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy the packaged jar file from the build stage | ||
COPY --from=build /app/target/demo-0.0.1-SNAPSHOT.jar app.jar | ||
|
||
# Set environment variables for PostgreSQL connection | ||
ENV DATABASE_HOST=localhost | ||
ENV DATABASE_PORT=5432 | ||
ENV DATABASE_NAME=mydatabase | ||
ENV DATABASE_USER=myuser | ||
ENV DATABASE_PASSWORD=mypassword | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 8080 | ||
|
||
# Run the application | ||
ENTRYPOINT ["java", "-jar", "app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Getting Started | ||
|
||
### Reference Documentation | ||
For further reference, please consider the following sections: | ||
|
||
* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) | ||
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.3.0/maven-plugin/reference/html/) | ||
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.3.0/maven-plugin/reference/html/#build-image) | ||
* [Spring Web](https://docs.spring.io/spring-boot/docs/3.3.0/reference/htmlsingle/index.html#web) | ||
* [Spring Data JPA](https://docs.spring.io/spring-boot/docs/3.3.0/reference/htmlsingle/index.html#data.sql.jpa-and-spring-data) | ||
|
||
### Guides | ||
The following guides illustrate how to use some features concretely: | ||
|
||
* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/) | ||
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/) | ||
* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/) | ||
* [Accessing Data with JPA](https://spring.io/guides/gs/accessing-data-jpa/) | ||
|
Oops, something went wrong.