Skip to content

Commit be8f2e2

Browse files
authored
Merge pull request #36 from advian-oss/build_issues
try to avoid running out of disk space during the builds
2 parents cdb127f + 8d4d37f commit be8f2e2

File tree

5 files changed

+94
-25
lines changed

5 files changed

+94
-25
lines changed

.github/workflows/build.yml

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,32 @@ on:
55
workflow_dispatch: # Allow manual triggering
66

77
jobs:
8-
bake:
8+
bake_pyenv:
99
runs-on: ubuntu-latest
1010
steps:
11+
- name: Free Disk Space (Ubuntu)
12+
uses: jlumbroso/free-disk-space@main
13+
with:
14+
# this might remove tools that are actually needed,
15+
# if set to "true" but frees about 6 GB
16+
tool-cache: true
17+
android: true
18+
dotnet: true
19+
haskell: true
20+
large-packages: true
21+
docker-images: true # we want to re-download freshest layers anyway
22+
swap-storage: true
1123
-
1224
name: Checkout
1325
uses: actions/checkout@v4
26+
-
27+
name: Set up QEMU
28+
uses: docker/setup-qemu-action@v3
1429
-
1530
name: Set up Docker Buildx
1631
uses: docker/setup-buildx-action@v3
32+
with:
33+
buildkitd-config: ./buildkitd.toml
1734
-
1835
name: Login to DockerHub
1936
uses: docker/login-action@v3
@@ -30,12 +47,54 @@ jobs:
3047
run: |
3148
export DHUBREPO=advian
3249
./create_builds.py pyenv > pyenv.hcl
33-
./create_builds.py tox-base > tox-base.hcl
3450
3551
- name: Bake pyenv
3652
run: |
37-
docker buildx bake --pull --push --file ./pyenv.hcl
53+
docker buildx bake --pull --provenance=true --sbom=true --push --file ./pyenv.hcl
54+
# FIXME: How to copy the buildx cache between jobs ?
55+
bake_tox:
56+
runs-on: ubuntu-latest
57+
needs: bake_pyenv
58+
steps:
59+
- name: Free Disk Space (Ubuntu)
60+
uses: jlumbroso/free-disk-space@main
61+
with:
62+
# this might remove tools that are actually needed,
63+
# if set to "true" but frees about 6 GB
64+
tool-cache: true
65+
android: true
66+
dotnet: true
67+
haskell: true
68+
large-packages: true
69+
docker-images: true # we want to re-download freshest layers anyway
70+
swap-storage: true
71+
-
72+
name: Checkout
73+
uses: actions/checkout@v4
74+
-
75+
name: Set up QEMU
76+
uses: docker/setup-qemu-action@v3
77+
-
78+
name: Set up Docker Buildx
79+
uses: docker/setup-buildx-action@v3
80+
with:
81+
buildkitd-config: ./buildkitd.toml
82+
-
83+
name: Login to DockerHub
84+
uses: docker/login-action@v3
85+
with:
86+
username: ${{ secrets.DOCKERHUB_USERNAME }}
87+
password: ${{ secrets.DOCKERHUB_TOKEN }}
3888

39-
- name: Bake tox
89+
- name: Set up Python
90+
uses: actions/setup-python@v4
91+
with:
92+
python-version: 3.11
93+
94+
- name: Create bakefiles
95+
run: |
96+
export DHUBREPO=advian
97+
./create_builds.py tox-base > tox-base.hcl
98+
- name: Bake pyenv
4099
run: |
41-
docker buildx bake --pull --push --file ./tox-base.hcl
100+
docker buildx bake --pull --provenance=true --sbom=true --push --file ./tox-base.hcl

Dockerfile_alpine

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,19 @@ RUN apk add --no-cache \
2121
# githublab ssh
2222
&& mkdir -p -m 0700 ~/.ssh && ssh-keyscan gitlab.com github.com | sort > ~/.ssh/known_hosts \
2323
# install pyenv
24-
&& curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash \
25-
&& echo 'export PATH="/root/.pyenv/bin:/root/.cargo/bin:$PATH"' >> /root/.profile \
26-
&& echo 'eval "$(pyenv init --path)"' >> /root/.profile \
24+
&& curl -o /tmp/pyenv_setup.sh --keepalive-time 900 --proto '=https' --tlsv1.2 -vsSfL https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer \
25+
&& chmod +x /tmp/pyenv_setup.sh \
26+
&& /tmp/pyenv_setup.sh \
27+
&& echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile \
28+
&& echo 'export PATH="$PYENV_ROOT/bin:$HOME/.cargo/bin:$PATH"' >> ~/.profile \
29+
&& echo 'eval "$(pyenv init --path)"' >> ~/.profile \
2730
&& true
2831

2932
SHELL ["/bin/bash", "-lc"]
3033
ENTRYPOINT ["/bin/bash", "-lc"]
3134

35+
RUN pyenv install -l
36+
3237
##############################
3338
# Build the version resolver #
3439
##############################
@@ -63,7 +68,7 @@ FROM pyenv as tox-base
6368
COPY docker-entrypoint-tox.sh /
6469
RUN python -m pip install -U tox \
6570
&& curl -sSL https://install.python-poetry.org | python3 - \
66-
&& echo 'export PATH="/root/.local/bin:$PATH"' >> /root/.profile \
71+
&& echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.profile \
6772
&& true
6873
ONBUILD COPY . /app
6974
WORKDIR /app

Dockerfile_debian

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,19 @@ RUN apt-get update \
2828
# githublab ssh
2929
&& mkdir -p -m 0700 ~/.ssh && ssh-keyscan gitlab.com github.com | sort > ~/.ssh/known_hosts \
3030
# install pyenv
31-
&& curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash \
32-
&& echo 'export PATH="/root/.pyenv/bin:$HOME/.cargo/bin:$PATH"' >> /root/.profile \
33-
&& echo 'eval "$(pyenv init --path)"' >> /root/.profile \
31+
&& curl -o /tmp/pyenv_setup.sh --keepalive-time 900 --proto '=https' --tlsv1.2 -vsSfL https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer \
32+
&& chmod +x /tmp/pyenv_setup.sh \
33+
&& /tmp/pyenv_setup.sh \
34+
&& echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile \
35+
&& echo 'export PATH="$PYENV_ROOT/bin:$HOME/.cargo/bin:$PATH"' >> ~/.profile \
36+
&& echo 'eval "$(pyenv init --path)"' >> ~/.profile \
3437
&& true
3538

3639
SHELL ["/bin/bash", "-lc"]
3740
ENTRYPOINT ["/bin/bash", "-lc"]
3841

42+
RUN pyenv install -l
43+
3944
##############################
4045
# Build the version resolver #
4146
##############################
@@ -69,7 +74,7 @@ FROM pyenv as tox-base
6974
COPY docker-entrypoint-tox.sh /
7075
RUN python -m pip install -U tox \
7176
&& curl -sSL https://install.python-poetry.org | python3 - \
72-
&& echo 'export PATH="/root/.local/bin:$PATH"' >> /root/.profile \
77+
&& echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.profile \
7378
&& true
7479
ONBUILD COPY . /app
7580
WORKDIR /app

Dockerfile_ubuntu

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ ENV CFLAGS='-O2' \
1010

1111
RUN apt-get update \
1212
&& apt-get install -y --no-install-recommends \
13-
bash \
1413
cargo \
14+
bash \
1515
curl \
1616
ca-certificates \
1717
git-core \
@@ -21,22 +21,22 @@ RUN apt-get update \
2121
openssh-client \
2222
libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget \
2323
libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
24-
# No recent enough Rust in Ubuntu focal packages
25-
&& curl -o /tmp/rustup.sh --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
26-
&& chmod +x /tmp/rustup.sh \
27-
&& /tmp/rustup.sh -y \
28-
&& echo 'source "$HOME/.cargo/env"' >> /root/.profile \
2924
# githublab ssh
3025
&& mkdir -p -m 0700 ~/.ssh && ssh-keyscan gitlab.com github.com | sort > ~/.ssh/known_hosts \
3126
# install pyenv
32-
&& curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash \
33-
&& echo 'export PATH="/root/.pyenv/bin:/root/.cargo/bin:$PATH"' >> /root/.profile \
34-
&& echo 'eval "$(pyenv init --path)"' >> /root/.profile \
27+
&& curl -o /tmp/pyenv_setup.sh --keepalive-time 900 --proto '=https' --tlsv1.2 -vsSfL https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer \
28+
&& chmod +x /tmp/pyenv_setup.sh \
29+
&& /tmp/pyenv_setup.sh \
30+
&& echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile \
31+
&& echo 'export PATH="$PYENV_ROOT/bin:$HOME/.cargo/bin:$PATH"' >> ~/.profile \
32+
&& echo 'eval "$(pyenv init --path)"' >> ~/.profile \
3533
&& true
3634

3735
SHELL ["/bin/bash", "-lc"]
3836
ENTRYPOINT ["/bin/bash", "-lc"]
3937

38+
RUN pyenv install -l
39+
4040
##############################
4141
# Build the version resolver #
4242
##############################
@@ -70,7 +70,7 @@ FROM pyenv as tox-base
7070
COPY docker-entrypoint-tox.sh /
7171
RUN python -m pip install -U tox \
7272
&& curl -sSL https://install.python-poetry.org | python3 - \
73-
&& echo 'export PATH="/root/.local/bin:$PATH"' >> /root/.profile \
73+
&& echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.profile \
7474
&& true
7575
ONBUILD COPY . /app
7676
WORKDIR /app

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ available on the host:
5858
./create_builds.py pyenv > pyenv.hcl
5959
./create_builds.py tox-base > tox-base.hcl
6060
docker login
61-
docker buildx bake --pull --push --file ./pyenv.hcl
62-
docker buildx bake --pull --push --file ./tox-base.hcl
61+
docker buildx bake --pull --push --file ./pyenv.hcl --provenance=true --sbom=true
62+
docker buildx bake --pull --push --file ./tox-base.hcl --provenance=true --sbom=true
6363

6464
The `create_builds.py` script output includes the Docker commands above as HCL file comments.

0 commit comments

Comments
 (0)