Running server in gitlab CI and running tests against it

Hi,

What i am trying to do is run my server in gitlab CI and run tests against it.
When i run my test against my deployed server everything works fine tests pass.
But i run the server in gitlab CI and then run tests after some time i get client disconnected. ( server is running i tried sending a curl request and it worked fine )

I also tried creating a docker image for my server and adding it as a service
but the server does not seem to run
eg docker image

FROM python:3
EXPOSE 8000
CMD nohup python -m http.server 8000 &

In my .gitlab-ci.yml file

test:
  stage: test
  services:
    - repo/testimage
  script:
    - ps -ef
    - curl -i http://localhost:8000 --insecure

the curl request gives connection refused