Reputation: 176
I want to use https://gitlab.com/ric_harvey/nginx-php-fpm as base Gitlab CI image with docker executor. But this image has many configurations eg. WEBROOT. I need this WEBROOT set to my own value. It is possible when run it in Gitlab CI?
I already try (won't work):
All seems to be too late, what i need is to edit start command for docker as:
docker run -e "WEBROOT=xxx" ...
.
image: richarvey/nginx-php-fpm:1.1.1
variables:
WEBROOT: "/build/domotron/cloud/www" <- this wont work
before_script:
## Install ssh-agent if not already installed, it is required by Docker.
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
## Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
## We're using tr to fix line endings which makes ed25519 keys work
## without extra base64 encoding.
## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
## Create the SSH directory and give it the right permissions
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
## Setup git
- git config --global user.email "email"
- git config --global user.name "User"
## Use ssh-keyscan to scan the keys of your private server.
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
stages:
- test
Codeception:
stage: test
services:
- name: selenium/standalone-chrome
alias: chrome
script:
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install --no-interaction
- php vendor/bin/codecept run
Upvotes: 2
Views: 12427
Reputation: 8636
As far as you cant overload entrypoint
for your builder image:
https://docs.gitlab.com/runner/executors/docker.html#the-image-keyword
The Docker executor doesn’t overwrite the ENTRYPOINT of a Docker image.
I suggest that you create your own image, based on richarvey/nginx-php-fpm:1.1.1
, and use it for building.
You can prepend one step into your pipeline, where you prepare needed tools like your own builders:
gitlab-ci.yaml
stages:
- prepare
- build
- ...
prepare-build-dockers:
stage: prepare
image: docker:stable
script:
- export WEBROOT
- build -t my-builder Dockerfiles
Dockerfiles/Dockerfile
FROM richarvey/nginx-php-fpm:1.1.1
Btw gitlab now supports custom docker registries, so having your own images for build/test/deploy is a good practice.
Upvotes: 2