package
0.0.0-20241003104419-c592368fdc93
Repository: https://github.com/dyrector-io/dyrectorio.git
Documentation: pkg.go.dev

# README

dyrector.io platform: dagent

We are working on the source code documentation, until then please use the root README.md for further information or check our official documentation site.

Implement the current interface for Docker deployments.

Swagger

go get -u github.com/swaggo/swag/cmd/swag

Regenerate swagger files - this is not automatic, please execute on change

swag init --parseDependency --parseInternal --parseVendor

Swagger is available on a running instance at eg. http://localhost:8080/swagger/index.html# Note the index.html is important to refer explicitly.

Debug

Needed for debugging:

Debug locally using Remote Instance

  1. Install ngrok - https://ngrok.com/
  2. Start DAgent locally
  3. Add/Modify your ngrok URL using the dyrector.io UI eg. d41a98d7ba2c.ngrok.io

Linting

https://golangci-lint.run/

Run installed tool with like so

AUR install

paru -S golangci-lint
golangci-lint run

Test

Execution of tests of the package with verbose output

go test -v ./...
# add -race flag to include testing for race conditions

Calculate coverage

./dev/coverage.sh
# the relative route is important

Environment variables

DATA_MOUNT_PATH=/srv/dagent
GIN_MODE=release

Deployment

Docker connection is needed, mount host /var/run/docker.sock into the container.

DYO_GRPC_ADDRESS or PORT is needed to bind gRPC or http services respectively.

At present, in gRPC dagent has client role so the port binding is implicit, no explicit port exposure is needed.

Configuration will prioritize Environmental Variables, .env file, and defaults in this order with Environmental variables taking the highest priority.

Configuration will take place before starting up the application, and store the configuration options in a global variable, which can be accessed during runtime. Both crane and DAgent have their own configuration package to add their own defaults and/or add their own custom variables. When the variables are used to achieve similar functions, can be found in both projects, and have the same defaults; then it can be found in a "common" config package. Please see the common README.md for more.

Environmental VariableDescriptiondefault value
AGENT_CONTAINER_NAMEname of the containerdagent-go
DAGENT_IMAGEFully qualified image name with registry incl. without protocolghcr.io/dyrector-io/dyrectorio/dagent
NAMEDAgent container name, it is needed for the updatedagent
DATA_MOUNT_PATHThis should match the mount path that is the root of configurations and containers/srv/dagent
DEFAULT_TAGdefault tag to use with container images in deploymentlatest
HOST_DOCKER_SOCK_PATHPath of docker.sock or other local/remote address where we can communicate with docker/var/run/docker.sock
INTERNAL_MOUNT_PATHContainers mount path default/srv/dagent
LOG_DEFAULT_SKIPLoglines to skip0
LOG_DEFAULT_TAKELoglines to take100
MIN_DOCKER_VERSIONMinimum required docker version, it's exposed to help debugging and also help podman users20.10
TRAEFIK_ACME_MAILE-mail address to use for dynamic certificate requestsnone
TRAEFIK_ENABLEDself explanatoryfalse
TRAEFIK_LOG_LEVELLoglevel for Traefiknone
TRAEFIK_TLSWhether to enable traefik TLS or notfalse
UPDATER_CONTAINER_NAMEContainer name for the updater container, useful if multiple instances are runningdagent-updater
UPDATE_HOST_TIMEZONEWhether to mount localtime into the update containertrue
UPDATE_METHODValues: off, webhook, polloff
UPDATE_POLL_INTERVALAgent polling frequency, should be defined in time.Duration parseable format (eg. 10s, 20m, 1h20m, 4395s etc)600s
WEBHOOK_TOKENToken used by the webhook to trigger the updatenone

Example docker run command

docker run \
  --name dagent-go \
  -p 9923:8080 \
  -e GIN_MODE=release \
  -e DATA_MOUNT_PATH=/home/nandor/.dagent \
  -e UPDATE_REGISTRY_USER='registry' \
  -e UPDATE_REGISTRY_PASSWORD='password' \
  -e WEBHOOK_TOKEN=UUID-TOKEN \
  -e DISCORD_WEBHOOK_URL="your_webhook_url" \
  -e HOSTNAME=$(HOST) \
  -e UPDATE_METHOD=poll \
  -v /home/nandor/.dagent:/srv/dagent \
  -v /var/run/docker.sock:/var/run/docker.sock  \
  --restart unless-stopped \
  -d  \
  ghcr.io/dyrector-io/dyrectorio/dagent:latest

Update

Webhook example with cURL

curl -X POST localhost:8080/update -H "Content-Type: application/json" \
-d '{"token": "UUID-TOKEN"}'

TLS

Server-side TLS is downloaded upon connection to the server (if need be).

Questions

If you have any questions please ask your teammates and extend the documentation with the missing pieces. Thanks ✌️

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
traefik functions related to deployment.

# Functions

No description provided by the author