Hi community
I have a pipeline where a stack (service) is deployed to my docker swarm. I want to use $CI_PROJECT_NAME in my docker service definition file to define the docker service name. But it seems the variable is not being expanded, or something else is wrong. I need to have a generic yml
so I can distribute this to all devs and they don’t have to change anything.
Example of what I am trying to achieve:
version: '3.9'
services:
$CI_PROJECT_NAME:
image: myregistry/devops1/$CI_PROJECT_NAME/$CI_PROJECT_NAME:latest
deploy:
replicas: 3
endpoint_mode: dnsrr
update_config:
parallelism: 1
delay: 3s
order: start-first
failure_action: rollback
monitor: 1m
restart_policy:
max_attempts: 3
placement:
max_replicas_per_node: 1
networks:
- microservices
volumes:
- apache-logs:/var/log/
networks:
microservices:
external: true
volumes:
apache-logs:
driver: local
driver_opts:
o: bind
device: /mnt/swarm_shared/services/$CI_PROJECT_NAME
type: none
I know this is not a docker forum, but was thinking the issue is with my pipeline rather than my docker compose file. I would appreciate any help I can get. TIA
EDIT: As per this community post I used a sed replacement command to solve my problem. Ugly, but functional.
Thanks for the input!
I don’t know for sure but would guess that you can’t use a var for that key you have close to the top?
Maybe you could tokenize? Not sure if you want to add another layer of problems here 😅.