- Build the image:
PHP_VERSION=[php_version] ./bin/build.sh
- Write
.gitlab-ci.yml
usingridibooks/platform-php-ci:[php_version]
as a base image in your project. - To run CI task on local machine, install GitLab Runner.
- Run
gitlab-runner
in the project dir. e.g.:
gitlab-runner exec docker [task_name] \
--docker-pull-policy=never \
--docker-volumes=/var/run/docker.sock:/var/run/docker.sock \
--env AWS_ACCESS_KEY_ID=aws_access_key_id \
--env AWS_SECRET_ACCESS_KEY=aws_secret_access_key \
--env SSH_PRIVATE_KEY="$(cat ~/.ssh/id_rsa)" \
--env DOCKER_IMAGE=docker_image
Options for gitlab-runner exec docker
:
--docker-pull-policy=never
: Use local image instead of pulling from remote.--docker-volumes=/var/run/docker.sock:/var/run/docker.sock
: Bind socket to build Docker images within CI container. For more options, see GitLab Documentation.--env [value] ...
: Pass env variables to CI container.
Note: If a variable in
.gitlab-ci.yml
has the same name as env variable like below,# .gitlab-ci.yml variables: SSH_PRIVATE_KEY: ${SSH_PRIVATE_KEY}# bash gitlab-runner exec docker ... --env SSH_PRIVATE_KEY="$(cat ~/.ssh/id_rsa)"GitLab Runner can not pass the value of env variable appropriately. So, you may need to do one of followings:
- Temporarily remove the variable from
.gitlab-ci.yml
.- Use the different variable name.
This will occur only when using GitLab Runner (not GitLab CI).