-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workflow docker image - pipeline (#533)
- Loading branch information
1 parent
3fcc555
commit d3a89c5
Showing
1 changed file
with
82 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Docker Image CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Build the Docker image | ||
run: docker build . --file Dockerfile --tag grandnode2:pr-latest | ||
|
||
- name: Start MongoDB container | ||
run: | | ||
docker run --name mongodb-container -d -p 27017:27017 mongo:latest | ||
- name: Wait for MongoDB to be ready | ||
run: | | ||
echo "Waiting for MongoDB to start..." | ||
for i in {1..10}; do | ||
nc -z localhost 27017 && echo "MongoDB is up" && break | ||
echo "Retrying in 3 seconds..." | ||
sleep 3 | ||
done | ||
- name: List Docker images | ||
run: docker images | ||
|
||
|
||
- name: Run the application container | ||
run: | | ||
docker run --name grandnode2-container -d -p 8080:8080 --link mongodb-container:mongo grandnode2:pr-latest | ||
- name: Wait for the application to be ready | ||
run: | | ||
echo "Waiting for the application to start..." | ||
for i in {1..10}; do | ||
curl -s http://localhost:8080 && echo "Application is up!" && break | ||
echo "Retrying in 3 seconds..." | ||
sleep 3 | ||
done | ||
- name: Trigger the installer via POST request | ||
run: | | ||
echo "Running installation with form-data..." | ||
curl -X POST http://localhost:8080/install \ | ||
-H "Content-Type: multipart/form-data" \ | ||
-F "[email protected]" \ | ||
-F "AdminPassword=SecurePassword123" \ | ||
-F "ConfirmPassword=SecurePassword123" \ | ||
-F "DataProvider=0" \ | ||
-F "MongoDBServerName=mongo" \ | ||
-F "MongoDBDatabaseName=grandnode" \ | ||
-F "InstallSampleData=true" \ | ||
-F "CompanyName=My Company" \ | ||
-F "CompanyAddress=123 Main St" \ | ||
-F "CompanyPhoneNumber=1234567890" \ | ||
-F "[email protected]" | ||
- name: Restart the application container | ||
run: | | ||
docker restart grandnode2-container | ||
- name: Test HTTP response after installation | ||
run: | | ||
echo "Waiting for the application to start..." | ||
for i in {1..10}; do | ||
curl -s http://localhost:8080 && echo "Application is up!" && break | ||
echo "Retrying in 3 seconds..." | ||
sleep 3 | ||
done | ||
- name: Stop and remove the container | ||
run: | | ||
docker stop grandnode2-container | ||
docker rm grandnode2-container |