Skip to content

Commit

Permalink
Workflow docker image - pipeline (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofPajak authored Nov 29, 2024
1 parent 3fcc555 commit d3a89c5
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/docker-image-pr.yml
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

0 comments on commit d3a89c5

Please sign in to comment.