I’m trying to use krakend’s flexible configuration, but there’s no way to get it started in a simple way
ERROR parsing the configuration file: loading flexible-config settings:
2022-07-19T08:48:21.279006680Z – "config/settings/dev": open "config/settings/dev": no such file or directory
I’m just trying to load a configuration file with a simple variable, to test the gateway.
but I’m not assigning that variable anywhere for now
dev/env.json
{
"port": 8080
}
I show you my configuration of docker-compose.yaml
shared-gateway:
build:
context: ${PWD}/.docker/krakend
container_name: 'shared-gateway'
restart: "unless-stopped"
volumes:
- ${PWD}/.docker/krakend/:/etc/krakend/
ports:
- "9191:8080"
networks:
- network-gateway
environment:
- FC_ENABLE=1
- FC_SETTINGS="config/settings/dev"
command: ['run', '-c', '/etc/krakend/krakend.json']
Dockerfile
FROM devopsfaith/krakend:2.0.5
COPY krakend.json /etc/krakend/krakend.json
I show you my directory tree
.
├── Dockerfile
├── config
│ ├── partials
│ ├── settings
│ │ ├── dev
│ │ │ └── env.json
│ │ └── prod
│ └── templates
└── krakend.json
When I start the container, it tells me that it can’t find the directory
ERROR parsing the configuration file: loading flexible-config settings:
2022-07-19T09:25:12.390870759Z – "config/settings/dev": open "config/settings/dev": no such file or directory
Does anyone know where I’m going wrong or have an example of how to use krakend’s flexible-configuration with docker?
2
Answers
It seems you either don’t copy the "config" directory into directory "/etc/krakend/" in your docker image or mount it ("config") from outside in your docker compose file. I believe the the image work directory is at "/etc/krakend", so make sure you make your config folder available under that directory, before you start "run" command
The problem is that the
config
folder is not present in your Docker image. I would suggest using thisDockerfile
example that uses Flexible Configuration that does exactly what you want:https://www.krakend.io/docs/deploying/docker/