I created a Spring sample, and tried to build the application into a Docker image and run the application in Docker container and perform a simple Smoke test to make sure the image is created as expected.
The Docker image is created by the Spring boot maven plugin.
I created a simple docker-compose file to run the application and database together.
version: "3.5" # specify docker-compose version, v3.5 is compatible with docker 17.12.0+ # Define the services/containers to be run services: db: image: mysql:8 ports: - "3306:3306" # command: --default-authentication-plugin=mysql_native_password environment: MYSQL_ROOT_PASSWORD: mysecret MYSQL_USER: user MYSQL_PASSWORD: password MYSQL_DATABASE: testdb volumes: - ./data/mysql:/var/lib/mysql - ./mysql-initdb.d:/docker-entrypoint-initdb.d app: image: hantsy/rest-many-to-many-example depends_on: - db ports: - "8080:8080" environment: - "SPRING_PROFILES_ACTIVE=dev" - "SPRING_DATASOURCE_URL=jdbc:mysql://db:3306/testdb"
In the Github actions workflow, it does not work, a Java test(or using curl command) failed to connect to http://localhost:8080 in the same flow.
The Github actions workflow file is here.
But it worked well on my local machine, accessing http://localhost:8080 is working as expected.