You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I'm trying to run elasticsearch docker image as a service alongside my pipelines CI, however some of the configuration options we would like to specify as environment vars for elasticsearch have periods in the name eg. discovery.type, and pipelines does not seem to allow variable names with a period in them.
I'm wondering what options there are to work around this, is it possible to bind the es config file to one in our repository, or some other way to get such named options through? Or would creating a custom docker image with our desired config be the only way to do this for now?
That's a shame and really confusing that environment format is not documented.
As an example this yml file passes in the validator https://bitbucket-pipelines.prod.public.atl-paas.net/validator
- apk update && apk add git openssh
- sed -i 's/<env name="LOCATION_SEARCH_ELASTICSEARCH_SERVER" value="localhost:9999"\/>/<env name="LOCATION_SEARCH_ELASTICSEARCH_SERVER" value="localhost:9200"\/>/' phpunit.xml
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- composer install
- cp .env.example .env
- php artisan key:generate
- "ES_JAVA_OPTS=-Xmx512m -Xms512m"
But pipelines keep saying to use a different format.
However nothing is mentioned about it here
So basically if docker image uses not underscore but period in env variables there is no way around it in bitbucket pipelines:)
@Nathan_Rzepecki well, solution is to create your own image, e.g.:
RUN chown -R :elasticsearch /usr/share/elasticsearch/data
ENV discovery.type single-node
And use it in pipeline yml as:
# This is a sample build configuration for PHP.
# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
# Only use spaces to indent your .yml configuration.
# You can specify a custom docker image from Docker Hub as your build environment.
- composer install
ES_JAVA_OPTS: '-Xms512m -Xmx512m'
I intentionally don't use cache for composer as it starts everything simultaneously. So for elastisearch it takes around 10-15 sec and composer install ~20 sec. Not sure what would be the best approach here. Other potential option is to use bash script with while.
You can use my docker image: https://hub.docker.com/r/xiting/elasticsearch-bitbucket-pipeline
It is based on fresh Elasticsearch version: 7.3.2
Add service to your pipeline as below:
definitions: steps: - step: &run-tests name: Run tests script: - sleep 30 # Waiting elasticsearch. In your real pipeline you can not use it. - curl -XGET localhost:9250/_cat/health services: - elasticsearch services: elasticsearch: image: xiting/elasticsearch-bitbucket-pipeline variables: ES_JAVA_OPTS: '-Xms512m -Xmx512m' docker: memory: 2048 pipelines: pull-requests: '**': - step: *run-tests
@Andrii Soldatenko I managed to but I had to build a custom docker image with my variables in the docker compose, like discovery.type