Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable substitution for TOML config in Docker Compose - how to make it happen? #4212

Closed
1 of 11 tasks
Kenya-West opened this issue May 11, 2024 · 2 comments
Closed
1 of 11 tasks

Comments

@Kenya-West
Copy link
Contributor

Kenya-West commented May 11, 2024

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

  1. Dockerize frps;
  2. Define variable in .env file;
  3. Set the variable as a value in frps.toml;
  4. docker compose up -d frps the instance;
  5. 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
@Kenya-West
Copy link
Contributor Author

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?

@Kenya-West
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant