Variable substitution for TOML config in Docker Compose - how to make it happen?
Kenya-West opened this issue · comments
Bug Description
I try to substitute variables set in frps.toml.template
file for dockerized frps instance and make Docker to produce frps.toml
file in mounted dir:
docker-compose.yml:
version: '3.8'
services:
frps:
image: snowdreamtech/frps
container_name: frps
restart: unless-stopped
env_file:
- .env
volumes:
- ./config-frps:/etc/frp # there lies frps.toml.template and should have been frps.toml
network_mode: host
volumes:
certs:
external: true
name: caddy_caddy-certs
.env:
DOMAIN=example.com # your domain
FRP_CADDY_PATH=frp # must be present, or it produces bugs. Example value: `frps`
FRPS_SERVER_PORT=7000 # port of the server
FRPS_AUTH_METHOD=token # authentication method
FRPS_AUTH_TOKEN=token # authentication token
FRPS_DASHBOARD_PORT=7500 # port of the dashboard (server)
FRPS_DASHBOARD_USER=admin # frps dashboard username
FRPS_DASHBOARD_PASSWORD=admin # frps dashboard password
FRPC_DASHBOARD_PORT=7400 # port of the dashboard (client)
FRPC_DASHBOARD_USER=admin # frpc dashboard username
FRPC_DASHBOARD_PASSWORD=admin # frpc dashboard password
config-frps/frps.toml.template
bindPort = ${FRPS_SERVER_PORT}
allowPorts = [
{ start = 22001, end = 22089 }
]
webServer.addr = "0.0.0.0"
webServer.port = ${FRPS_DASHBOARD_PORT}
webServer.user = "${FRPS_DASHBOARD_USER}"
webServer.password = "${FRPS_DASHBOARD_PASSWORD}"
auth.method = "${FRPS_AUTH_METHOD}"
auth.token = "${FRPS_AUTH_TOKEN}"
frps
(or Docker itself) does not substitute variables and does not produce frps.toml
file inside the container:
frps | 2024-05-12T10:32:51.902635600Z open /etc/frp/frps.toml: no such file or directory
How to force Docker to create frps.toml
file?
frpc Version
0.56.1
frps Version
0.56.1
System Architecture
linux/amd64
Configurations
Logs
Steps to reproduce
- Dockerize
frps
; - Define variable in
.env
file; - Set the variable as a value in
frps.toml
; docker compose up -d frps
the instance;- See that variable is not substituted.
Affected area
- Docs
- Installation
- Performance and Scalability
- Security
- User Experience
- Test and Release
- Developer Infrastructure
- Client Plugin
- Server Plugin
- Extensions
- Others
Since I forgot to rename file from frps.toml
to frps.toml.template
and in result got other kind of error message, whole body of the question changed.
P. S. With NGINX, env substitution works. What's wrong with FRP?
UPD: Found out that environment variables substitution should be implemented on developer's side.
The tool envsubst
should be in Docker's image and executed during image building process.
Which means I need to go directly to snowdreamtech/frp and post an issue there.
Sorry for posting irrelevant problem here. This issue can now be closed.