Skip to content

Commit 2686b25

Browse files
committed
store docker image on /mnt
1 parent 9d3a935 commit 2686b25

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

.github/workflows/build_images.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,22 @@ jobs:
2121
- uses: actions/checkout@v3
2222
with:
2323
ref: refs/heads/main
24-
- name: Free Disk Space
24+
#- name: Free Disk Space
25+
# run: |
26+
# ./free_disk_space.sh
27+
- name: Store Docker Images on /mnt/docker
2528
run: |
26-
./free_disk_space.sh
29+
./docker.py
2730
- name: Login to DockerHub
2831
uses: docker/login-action@v3
2932
with:
3033
username: ${{ secrets.DOCKERHUB_USERNAME }}
3134
password: ${{ secrets.DOCKERHUB_TOKEN }}
3235
- name: Build Docker Images
3336
run: |
34-
df -lh
35-
docker ps
37+
#df -lh
38+
#docker ps
3639
./build_images.py --branch '${{ github.event.inputs.branch }}' --repo '${{ github.event.inputs.repo }}' --root-image-name '${{ github.event.inputs.root_image_name }}'
3740
cat graph.yaml
38-
docker ps
39-
df -lh
41+
#docker ps
42+
#df -lh

docker.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python3
2+
import json
3+
from pathlib import Path
4+
import subprocess as sp
5+
6+
7+
def config_data_root(data_root: str) -> dict[str, str]:
8+
Path(data_root).mkdir(parents=True, exists_ok=True)
9+
settings = {}
10+
path = Path("/etc/docker/daemon.json")
11+
if path.is_file():
12+
with path.open("r", encoding="utf-8") as fin:
13+
settings = json.load(fin)
14+
settings["data-root"] = data_root
15+
with path.open("w", encoding="utf-8") as fout:
16+
json.dump(settings, fout, indent=4)
17+
return settings
18+
19+
20+
def store_docker_on_mnt():
21+
sp.run(cmd="systemctl stop docker", shell=True, check=True)
22+
settings = config_data_root("/mnt/docker")
23+
print(settings)
24+
sp.run(cmd="systemctl start docker", shell=True, check=True)
25+
sp.run(cmd="docker info", shell=True, check=True)
26+
27+
28+
if __name__ == "__main__":
29+
store_docker_on_mnt()
30+

0 commit comments

Comments
 (0)