I have the following GitHub workflow for building my project
name: build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn clean compile test
The build works just fine. However the project JUnit test require that a localhost server is listening on port 4444 ... and I get the following error:
Connection refused: localhost/127.0.0.1:4444
The server is spun up before each JUnit test and is part of the tests suite.
How do I tell the docker container that network connections are allowed on this port? Or are there any open ports by default?
I share my solution. Hopefully it will help.
FROM golang:1.15.2-alpine
# Setup you server
# This container exposes port 8080 to the outside world
EXPOSE 8080
# Run the executable
CMD ["./main"]
main-server:
build: ./
container_name: main-server
image: artofimagination/main-server
ports:
- 8080:8080
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Start test server
run: docker-compose up -d main-server
- name: Run functional test
run: pip3 install -r test/requirements.txt && pytest -v test
Good luck and I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With