I'm aiming to deploy an environment for testing. It's a PHP application, and I could simply serve the PHP files using the embedded server.
My .gitlab-ci.yml is plain simple:
docker_test:
stage: deploy
image: php:7.2
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
environment:
name: development/$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
url: $CI_SERVER_PROTOCOL://$CI_SERVER_HOST:8000/$CI_PROJECT_PATH_SLUG/$CI_ENVIRONMENT_SLUG:8000
auto_stop_in: 1 hour
script:
- php -S 0.0.0.0:8000 -t /builds/$CI_PROJECT_PATH
What I want is: When pipeline runs, the environment will be live, the container should be up and running, and a tester should be able to access it using the URL. After one hour, or if Stop button is pressed, environment shoud stop and Docker container stopped and removed. However, I don't figure out yet, how to keep the container running in the background. When pipeline is executed, it freezes on the script, and when it's cancelled, Docker container is stopped.
Any idea on how to achieve this?