Skip to content

Commit

Permalink
Merge pull request #1853 from ten-protocol/anthony/v0.23-patch-log-ro…
Browse files Browse the repository at this point in the history
…lling

v0.23 release patch for rotating/trimming docker logs (#3116)
  • Loading branch information
anixon604 authored Mar 28, 2024
2 parents 83c037c + a4c8513 commit b435845
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/runner-scripts/create-vm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@ az vm create \
--resource-group Testnet \
--name MakeImageVM \
--image Canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:20.04.202206220 \
--security-type 'Standard' \
--admin-username obscurouser --admin-password 'PWD'

ssh obscurouser@IPADDRESS

sudo apt-get update \
&& sudo apt-get install -y gcc \
&& sudo snap refresh && sudo snap install --channel=1.20 go --classic \
&& sudo snap refresh && sudo snap install go --channel=1.21/stable --classic \
&& curl -fsSL https://get.docker.com -o get-docker.sh && sh ./get-docker.sh

exit

az vm deallocate --resource-group Testnet --name MakeImageVM
az vm generalize --resource-group Testnet --name MakeImageVM
az image delete --resource-group Testnet --name ObscuroConfUbuntu
az image create --resource-group Testnet --name ObscuroConfUbuntu --source MakeImageVM --hyper-v-generation V2

az vm delete --resource-group Testnet --name MakeImageVM --yes
az disk delete --resource-group Testnet --name MakeImageVM_OSDisk --yes
az network nic delete --resource-group Testnet --name MakeImageVM_NIC
az disk delete --resource-group Testnet --name MakeImageVM_OsDisk-<get uuid from azure> --yes --no-wait
az network nic delete --resource-group Testnet --name MakeImageVMVMNIC --no-wait

7 changes: 7 additions & 0 deletions go/common/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ func StartNewContainer(containerName, image string, cmds []string, ports []int,
exposedPorts[nat.Port(fmt.Sprintf("%d/tcp", port))] = struct{}{}
}

// set log rotations
logOptions := map[string]string{
"max-size": "10m",
"max-file": "3",
}

// create the container
resp, err := cli.ContainerCreate(ctx, &container.Config{
Image: image,
Expand All @@ -101,6 +107,7 @@ func StartNewContainer(containerName, image string, cmds []string, ports []int,
PortBindings: portBindings,
Mounts: mountVolumes,
Resources: container.Resources{Devices: deviceMapping},
LogConfig: container.LogConfig{Type: "json-file", Config: logOptions},
},
&network.NetworkingConfig{
EndpointsConfig: map[string]*network.EndpointSettings{
Expand Down

0 comments on commit b435845

Please sign in to comment.