cenk1cenk2 / docker-softether-vpnsrv

SoftEther VPN Server with DNSMASQ DHCP Server or bridge mode connection for VPN-to-site setup.
29 stars 15 forks source link

Hi could you please give me some info on how to populate the .env file. #29

Closed Dewtah closed 1 year ago

Dewtah commented 1 year ago

I have tried a lot, but when using docker compose, it first says that the .env file is missing. When creating one (which with i thought default vars) it doesn't seem to be recognized by the build process of the container. So I suppose my syntax inside the .env file is with a wrong syntax. I have tried: LINUX_BRIDGE_INTERFACE_NAME="bridge"

$LINUX_BRIDGE_INTERFACE_NAME="bridge"

LINUX_BRIDGE_INTERFACE_NAME "bridge"

Is it perhaps json syntax? If so what are its dict/array names

And all sorts of combo's Then I noticed it get loaded with pipe from golang. Which you have another repo for. So the questions also arose if I needed to install or do something with that.

Edit: No json doesn't get parsed all

Anyway's a little help would be much appreciated.

cenk1cenk2 commented 1 year ago

Hey @Dewtah,

No worries. Will try to explain it further on.

The docker-compose.yml file on the root of the repository is mostly for testing and demonstration purposes, you can use the latest version from DockerHub instead of actually building it.

version: '3.7'
services:
  softether-vpnsrv:
    image: cenk1cenk2/softether-vpnsrv:latest
    env_file: .env
    devices:
      - /dev/net/tun
    ports:
      - 1443:1443/tcp
      - 992:992/tcp
      - 5555:5555/tcp
      - 1194:1194/udp
      - 500:500/udp
      - 4500:4500/udp
      - 1701:1701/tcp
    network_mode: bridge
    volumes:
      # Configuration Files
      - ./volumes/softether-vpnsrv:/conf
      # Log files
      - ./logs/server_log:/etc/softether/server_log
      - ./logs/security_log:/etc/softether/security_log
      - ./logs/packet_log:/etc/softether/packet_log
    cap_add:
      - SETGID
      - SETUID
      - NET_ADMIN
      - NET_RAW
      - NET_BIND_SERVICE

For the second part of it you can either create a environment variable file and indicate that the docker-compose stack should run with it as in the example like env_file: ./.env or you can also use the environment key inside the docker-compose specification.

$ sign in the front is just to indicate that it is an environment variable, since the documentation is autogenerated from the CLI flags where it can also have CLI flags like --something.

So to sumarize you can do:

version: '3.7'
services:
  softether-vpnsrv:
    image: cenk1cenk2/softether-vpnsrv:latest
    environment:
      LINUX_BRIDGE_INTERFACE_NAME: 'bridge'
    devices:
      - /dev/net/tun
    ports:
      - 1443:1443/tcp
      - 992:992/tcp
      - 5555:5555/tcp
      - 1194:1194/udp
      - 500:500/udp
      - 4500:4500/udp
      - 1701:1701/tcp
    network_mode: bridge
    volumes:
      # Configuration Files
      - ./volumes/softether-vpnsrv:/conf
      # Log files
      - ./logs/server_log:/etc/softether/server_log
      - ./logs/security_log:/etc/softether/security_log
      - ./logs/packet_log:/etc/softether/packet_log
    cap_add:
      - SETGID
      - SETUID
      - NET_ADMIN
      - NET_RAW
      - NET_BIND_SERVICE
Dewtah commented 1 year ago

Thanks a very lot. I was just toying around, since iv'e done this with Ansible, but I know that go can be more efficient. And for the most part u are using go to implement the variables trough the multiple layers of build, docker, and final image instead of the artifact function right? And as far as I can tell, your implementation is pretty solid.

cenk1cenk2 commented 1 year ago

Yeah, I wanted to standardize running commands in containers as CLI applications which can parse incoming environment variables and enable different stages, run tasks depending on the configuration since bash scripts were getting complicated to implement and read at some points.

Dewtah commented 1 year ago

Very good job, ill keep an eye out :) Thanks.

Dewtah commented 1 year ago

Sorry to bother you again,

whatever I try, I get

failed to create endpoint mystifying_franklin on network bridge: adding interface vethd652ad6 to bridge docker0 failed: could not find bridge docker0: route ip+net: no such network interface

At step 6. And can't seem to find anywhere where it is defined. Is this inherent to your building environment? Because my assumption was that the var LINUX_BRIDGE_INTERFACE_NAME: 'bridge' should be covering that.

ive tried to add in constants.go in the flags.co as .env and as environment in the docker-compose.yml