Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions agent/app/dto/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ type ContainerInfo struct {
Network []string `json:"network"`
Ports []string `json:"ports"`

SizeRw int64 `json:"sizeRw"`
SizeRootFs int64 `json:"sizeRootFs"`

IsFromApp bool `json:"isFromApp"`
IsFromCompose bool `json:"isFromCompose"`

Expand All @@ -45,14 +48,13 @@ type ContainerOptions struct {
}

type ContainerStatus struct {
All uint `json:"all"`
Created uint `json:"created"`
Running uint `json:"running"`
Paused uint `json:"paused"`
Restarting uint `json:"restarting"`
Removing uint `json:"removing"`
Exited uint `json:"exited"`
Dead uint `json:"dead"`
Created int `json:"created"`
Running int `json:"running"`
Paused int `json:"paused"`
Restarting int `json:"restarting"`
Removing int `json:"removing"`
Exited int `json:"exited"`
Dead int `json:"dead"`

ContainerCount int `json:"containerCount"`
ComposeCount int `json:"composeCount"`
Expand All @@ -62,7 +64,14 @@ type ContainerStatus struct {
VolumeCount int `json:"volumeCount"`
RepoCount int `json:"repoCount"`

ImageSize uint64 `json:"imageSize"`
ContainerUsage int64 `json:"containerUsage"`
ContainerReclaimable int64 `json:"containerReclaimable"`
ImageUsage int64 `json:"imageUsage"`
ImageReclaimable int64 `json:"imageReclaimable"`
VolumeUsage int64 `json:"volumeUsage"`
VolumeReclaimable int64 `json:"volumeReclaimable"`
BuildCacheUsage int64 `json:"buildCacheUsage"`
BuildCacheReclaimable int64 `json:"buildCacheReclaimable"`
}
type ResourceLimit struct {
CPU int `json:"cpu"`
Expand Down
47 changes: 35 additions & 12 deletions agent/app/service/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/1Panel-dev/1Panel/agent/utils/cmd"
"github.com/1Panel-dev/1Panel/agent/utils/common"
"github.com/1Panel-dev/1Panel/agent/utils/docker"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/build"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
Expand Down Expand Up @@ -105,7 +106,8 @@ func (u *ContainerService) Page(req dto.PageContainer) (int64, interface{}, erro
}
defer client.Close()
options := container.ListOptions{
All: true,
All: true,
Size: true,
}
if len(req.Filters) != 0 {
options.Filters = filters.NewArgs()
Expand Down Expand Up @@ -199,6 +201,8 @@ func (u *ContainerService) Page(req dto.PageContainer) (int64, interface{}, erro
Ports: exposePorts,
IsFromApp: IsFromApp,
IsFromCompose: IsFromCompose,
SizeRw: item.SizeRw,
SizeRootFs: item.SizeRootFs,
}
install, _ := appInstallRepo.GetFirst(appInstallRepo.WithContainerName(info.Name))
if install.ID > 0 {
Expand Down Expand Up @@ -282,11 +286,35 @@ func (u *ContainerService) LoadStatus() (dto.ContainerStatus, error) {
}
defer client.Close()
c := context.Background()
images, _ := client.ImageList(c, image.ListOptions{})
for _, image := range images {
data.ImageSize += uint64(image.Size)

usage, err := client.DiskUsage(c, types.DiskUsageOptions{})
if err != nil {
return data, err
}

data.ImageCount = len(usage.Images)
data.VolumeCount = len(usage.Volumes)
for _, item := range usage.Images {
data.ImageUsage += item.Size
if item.Containers < 1 {
data.ImageReclaimable += item.Size
}
}
for _, item := range usage.Containers {
data.ContainerUsage += item.SizeRw
if item.State != "running" {
data.ContainerReclaimable += item.SizeRw
}
}
for _, item := range usage.Volumes {
data.VolumeUsage += item.UsageData.Size
if item.UsageData.RefCount == 0 {
data.VolumeReclaimable += item.UsageData.Size
}
}
for _, item := range usage.BuildCache {
data.BuildCacheUsage += item.Size
}
data.ImageCount = len(images)
repo, _ := imageRepoRepo.List()
data.RepoCount = len(repo)
templates, _ := composeRepo.List()
Expand All @@ -296,12 +324,8 @@ func (u *ContainerService) LoadStatus() (dto.ContainerStatus, error) {
volumes, _ := client.VolumeList(c, volume.ListOptions{})
data.VolumeCount = len(volumes.Volumes)
data.ComposeCount = loadComposeCount(client)
containers, err := client.ContainerList(c, container.ListOptions{All: true})
if err != nil {
return data, err
}
data.All = uint(len(containers))
for _, item := range containers {
data.ContainerCount = len(usage.Containers)
for _, item := range usage.Containers {
switch item.State {
case "created":
data.Created++
Expand All @@ -319,7 +343,6 @@ func (u *ContainerService) LoadStatus() (dto.ContainerStatus, error) {
data.Removing++
}
}
data.ContainerCount = int(data.All)
return data, nil
}
func (u *ContainerService) ContainerListStats() ([]dto.ContainerListStats, error) {
Expand Down
2 changes: 1 addition & 1 deletion core/app/api/v2/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (b *BaseApi) GetWelcomePage(c *gin.Context) {
}
file, err := os.ReadFile(path.Join(global.CONF.Base.InstallDir, "1panel/welcome/index.html"))
if err != nil {
helper.InternalServer(c, err)
helper.Success(c)
return
}
helper.SuccessWithData(c, string(file))
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/api/interface/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export namespace Container {
order: string;
}
export interface ContainerStatus {
all: number;
created: number;
running: number;
paused: number;
Expand All @@ -44,7 +43,14 @@ export namespace Container {
volumeCount: number;
repoCount: number;

imageSize: number;
containerUsage: number;
containerReclaimable: number;
imageUsage: number;
imageReclaimable: number;
volumeUsage: number;
volumeReclaimable: number;
buildCacheUsage: number;
buildCacheReclaimable: number;
}
export interface ContainerOption {
name: string;
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,19 @@ const message = {
inputIpv4: 'Example: 192.168.1.1',
inputIpv6: 'Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334',

diskUsage: 'Disk Usage',
localVolume: 'Local Storage Volume',
buildCache: 'Build Cache',
usage: 'Used: {0}, Releasable: {1}',
clean: 'Release',
imageClean: 'Clean up images will delete all unused images. This operation cannot be rolled back. Continue?',
containerClean:
'Clean up containers will delete all stopped containers (including stopped apps from App Store). This operation cannot be rolled back. Continue?',
sizeRw: 'Layer Size',
sizeRwHelper: 'Size of the writable layer unique to the container',
sizeRootFs: 'Virtual Size',
sizeRootFsHelper: 'Total size of all image layers the container depends on + container layer',

containerFromAppHelper:
'Detected that this container originates from the app store. App operations may cause current edits to be invalidated.',
containerFromAppHelper1:
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/lang/modules/es-es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,22 @@ const message = {
'El motor de contenedores usa un valor base de 1024 para la proporción de CPU. Puede aumentarlo para darle al contenedor más tiempo de CPU.',
inputIpv4: 'Ejemplo: 192.168.1.1',
inputIpv6: 'Ejemplo: 2001:0db8:85a3:0000:0000:8a2e:0370:7334',

diskUsage: 'Uso del Disco',
localVolume: 'Volumen de Almacenamiento Local',
buildCache: 'Caché de Construcción',
usage: 'Usado: {0}, Liberable: {1}',
clean: 'Liberar',
imageClean:
'Limpiar imágenes eliminará todas las imágenes no utilizadas. Esta operación no se puede deshacer. ¿Continuar?',
containerClean:
'Limpiar contenedores eliminará todos los contenedores detenidos (incluidas las aplicaciones detenidas de la Tienda de Aplicaciones). Esta operación no se puede deshacer. ¿Continuar?',
sizeRw: 'Tamaño de Capa de Contenedor',
sizeRwHelper: 'Tamaño de la capa escribible exclusiva del contenedor',
sizeRootFs: 'Tamaño Virtual',
sizeRootFsHelper:
'Tamaño total de todas las capas de imagen de las que depende el contenedor + capa del contenedor',

containerFromAppHelper:
'Se detectó que este contenedor proviene de la tienda de aplicaciones. Las operaciones sobre la app pueden invalidar los cambios actuales.',
containerFromAppHelper1:
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/lang/modules/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,20 @@ const message = {
inputIpv4: '例:192.168.1.1',
inputIpv6: '例:2001:0DB8:85A3:0000:0000:8A2E:0370:7334',

diskUsage: 'ディスク使用量',
localVolume: 'ローカルストレージボリューム',
buildCache: 'ビルドキャッシュ',
usage: '使用済み: {0}, 解放可能: {1}',
clean: '解放',
imageClean:
'イメージをクリーンアップすると、すべての未使用イメージが削除されます。この操作は元に戻せません。続行しますか?',
containerClean:
'コンテナをクリーンアップすると、停止中のすべてのコンテナ(アプリストアの停止アプリを含む)が削除されます。この操作は元に戻せません。続行しますか?',
sizeRw: 'コンテナレイヤーサイズ',
sizeRwHelper: 'コンテナ固有の書き込み可能レイヤーのサイズ',
sizeRootFs: '仮想サイズ',
sizeRootFsHelper: 'コンテナが依存するすべてのイメージレイヤー + コンテナレイヤーの合計サイズ',

containerFromAppHelper:
'このコンテナがアプリストアから取得されたことが検出されました。アプリの操作により、現在の編集が無効になる可能性があります。',
containerFromAppHelper1:
Expand Down
15 changes: 15 additions & 0 deletions frontend/src/lang/modules/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,21 @@ const message = {
'컨테이너 엔진은 기본값으로 1024를 사용합니다. 이를 늘리면 컨테이너에 더 많은 CPU 시간을 할당할 수 있습니다.',
inputIpv4: '예시: 192.168.1.1',
inputIpv6: '예시: 2001:0db8:85a3:0000:0000:8a2e:0370:7334',

diskUsage: '디스크 사용량',
localVolume: '로컬 스토리지 볼륨',
buildCache: '빌드 캐시',
usage: '사용됨: {0}, 해제 가능: {1}',
clean: '해제',
imageClean:
'이미지 정리를 수행하면 사용되지 않은 모든 이미지가 삭제됩니다. 이 작업은 되돌릴 수 없습니다. 계속하시겠습니까?',
containerClean:
'컨테이너 정리를 수행하면 중지된 모든 컨테이너(앱 스토어의 중지된 앱 포함)가 삭제됩니다. 이 작업은 되돌릴 수 없습니다. 계속하시겠습니까?',
sizeRw: '컨테이너 레이어 크기',
sizeRwHelper: '컨테이너에 고유한 쓰기 가능 레이어 크기',
sizeRootFs: '가상 크기',
sizeRootFsHelper: '컨테이너가 의존하는 모든 이미지 레이어 + 컨테이너 레이어의 총 크기',

containerFromAppHelper:
'이 컨테이너가 앱 스토어에서 왔음을 감지했습니다. 앱 작업으로 현재 편집이 무효화될 수 있습니다.',
containerFromAppHelper1:
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/lang/modules/ms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,20 @@ const message = {
inputIpv4: 'Contoh: 192.168.1.1',
inputIpv6: 'Contoh: 2001:0db8:85a3:0000:0000:8a2e:0370:7334',

diskUsage: 'Penggunaan Cakera',
localVolume: 'Isipadu Storan Tempatan',
buildCache: 'Cache Binaan',
usage: 'Digunakan: {0}, Boleh Dibebaskan: {1}',
clean: 'Bebaskan',
imageClean:
'Membersihkan imej akan memadam semua imej yang tidak digunakan. Operasi ini tidak boleh dikembalikan. Teruskan?',
containerClean:
'Membersihkan bekas akan memadam semua bekas yang dihentikan (termasuk aplikasi berhenti dari Kedai Apl). Operasi ini tidak boleh dikembalikan. Teruskan?',
sizeRw: 'Saiz Lapisan Bekas',
sizeRwHelper: 'Saiz lapisan boleh tulis yang unik untuk bekas',
sizeRootFs: 'Saiz Maya',
sizeRootFsHelper: 'Jumlah saiz semua lapisan imej yang disandarkan oleh bekas + lapisan bekas',

containerFromAppHelper:
'Dikesan bahawa kontena ini berasal dari gedung aplikasi. Operasi aplikasi boleh menyebabkan suntingan semasa menjadi tidak sah.',
containerFromAppHelper1:
Expand Down
15 changes: 15 additions & 0 deletions frontend/src/lang/modules/pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,21 @@ const message = {
inputIpv4: 'Exemplo: 192.168.1.1',
inputIpv6: 'Exemplo: 2001:0db8:85a3:0000:0000:8a2e:0370:7334',

diskUsage: 'Uso do Disco',
localVolume: 'Volume de Armazenamento Local',
buildCache: 'Cache de Build',
usage: 'Usado: {0}, Liberável: {1}',
clean: 'Liberar',
imageClean:
'Limpar imagens excluirá todas as imagens não utilizadas. Esta operação não pode ser desfeita. Continuar?',
containerClean:
'Limpar contêineres excluirá todos os contêineres parados (incluindo aplicativos parados da Loja de Aplicativos). Esta operação não pode ser desfeita. Continuar?',
sizeRw: 'Tamanho da Camada do Contêiner',
sizeRwHelper: 'Tamanho da camada gravável exclusiva do contêiner',
sizeRootFs: 'Tamanho Virtual',
sizeRootFsHelper:
'Tamanho total de todas as camadas de imagem das quais o contêiner depende + camada do contêiner',

containerFromAppHelper:
'Detectamos que este contêiner vem da loja de aplicativos. As operações no aplicativo podem fazer com que as edições atuais sejam invalidadas.',
containerFromAppHelper1:
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/lang/modules/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,19 @@ const message = {
inputIpv4: 'Пример: 192.168.1.1',
inputIpv6: 'Пример: 2001:0db8:85a3:0000:0000:8a2e:0370:7334',

diskUsage: 'Использование Диска',
localVolume: 'Локальный Том Хранилища',
buildCache: 'Кэш Сборки',
usage: 'Использовано: {0}, Можно освободить: {1}',
clean: 'Освободить',
imageClean: 'Очистка образов удалит все неиспользуемые образы. Это действие нельзя отменить. Продолжить?',
containerClean:
'Очистка контейнеров удалит все остановленные контейнеры (включая остановленные приложения из Магазина приложений). Это действие нельзя отменить. Продолжить?',
sizeRw: 'Размер Слоя Контейнера',
sizeRwHelper: 'Размер записываемого слоя, уникального для контейнера',
sizeRootFs: 'Виртуальный Размер',
sizeRootFsHelper: 'Общий размер всех слоев образа, от которых зависит контейнер + слой контейнера',

containerFromAppHelper:
'Обнаружено, что этот контейнер происходит из магазина приложений. Операции с приложением могут привести к недействительности текущих изменений.',
containerFromAppHelper1:
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/lang/modules/tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,20 @@ const message = {
inputIpv4: 'Örnek: 192.168.1.1',
inputIpv6: 'Örnek: 2001:0db8:85a3:0000:0000:8a2e:0370:7334',

diskUsage: 'Disk Kullanımı',
localVolume: 'Yerel Depolama Birimi',
buildCache: 'Derleme Önbelleği',
usage: 'Kullanılan: {0}, Serbest Bırakılabilir: {1}',
clean: 'Serbest Bırak',
imageClean:
'Görüntüleri temizlemek, kullanılmayan tüm görüntüleri silecektir. Bu işlem geri alınamaz. Devam etmek istiyor musunuz?',
containerClean:
'Konteynerleri temizlemek, durdurulmuş tüm konteynerleri (Uygulama Mağazası ndaki durdurulmuş uygulamalar dahil) silecektir. Bu işlem geri alınamaz. Devam etmek istiyor musunuz?',
sizeRw: 'Konteyner Katman Boyutu',
sizeRwHelper: 'Konteynere özel yazılabilir katman boyutu',
sizeRootFs: 'Sanal Boyut',
sizeRootFsHelper: 'Konteynerin bağımlı olduğu tüm görüntü katmanları + konteyner katmanının toplam boyutu',

containerFromAppHelper:
'Bu konteynerin uygulama mağazasından geldiği tespit edildi. Uygulama işlemleri mevcut düzenlemelerin geçersiz hale gelmesine neden olabilir.',
containerFromAppHelper1:
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/lang/modules/zh-Hant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,18 @@ const message = {
inputIpv4: '請輸入 IPv4 位址',
inputIpv6: '請輸入 IPv6 位址',

diskUsage: '磁碟佔用',
localVolume: '本機儲存卷',
buildCache: '建置快取',
usage: '已佔用:{0}, 可釋放:{1}',
clean: '釋放',
imageClean: '清理映像將刪除所有未被使用的映像,該操作無法復原,是否繼續?',
containerClean: '清理容器將刪除所有處於停止中狀態的容器(包括應用商店停止應用),該操作無法復原,是否繼續?',
sizeRw: '容器層大小',
sizeRwHelper: '容器獨有的可寫層大小',
sizeRootFs: '虛擬大小',
sizeRootFsHelper: '容器依賴的所有映像層 + 容器層的總大小',

containerFromAppHelper: '檢測到該容器來源於應用商店,應用操作可能會導致目前編輯失效',
containerFromAppHelper1: '在已安裝應用程式列表點擊 [參數] 按鈕,進入編輯頁面即可修改容器名稱。',
command: '指令',
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,18 @@ const message = {
inputIpv4: '请输入 IPv4 地址',
inputIpv6: '请输入 IPv6 地址',

diskUsage: '磁盘占用',
localVolume: '本地存储卷',
buildCache: '构建缓存',
usage: '已占用:{0}, 可释放:{1}',
clean: '释放',
imageClean: '清理镜像 将删除所有未被使用的镜像,该操作无法回滚,是否继续?',
containerClean: '清理容器 将删除所有处于停止中状态的容器(包括应用商店停止应用),该操作无法回滚,是否继续?',
sizeRw: '容器层大小',
sizeRwHelper: '容器独有的可写层大小',
sizeRootFs: '虚拟大小',
sizeRootFsHelper: ' 容器依赖的所有镜像层 + 容器层的总大小',

containerFromAppHelper: '检测到该容器来源于应用商店,应用操作可能会导致当前编辑失效',
containerFromAppHelper1: '在应用商店的已安装页面,点击 [参数] 按钮,进入编辑页面修改容器名称。',
command: '命令',
Expand Down
Loading
Loading