Skip to content

Commit 1a3f11c

Browse files
ABUCKY0meisZWFLZ
andauthored
🏋️‍♂️Putting the image on a serious diet (v4.0.0) (#13)
* Test Alpine linux (See Jerrylum/pros-build) * Update Dockerfile * Update Dockerfile * Use pipx * Update Dockerfile * Add root/.local/bin to path * Make build.sh in the root folder * Try specifying filename where to copy build.sh to * Update Dockerfile * Update Dockerfile * Change /build.sh to ~/build.sh * Update Dockerfile * Update Dockerfile * add sh and bash for good measure * Update Dockerfile * Put the toolchain on a serious diet * Comment out G++ * forgot to uncomment the path 💀 * add G++ back in * run ldd on each program in the dieted toolchain * try ldd again * Update Dockerfile * Update copied files * Change non-dieted files. * Add libexec to included files * add possibly missing / * Update Dockerfile * Remove extra folder from mkdir * remove -r flag * include arm-none-eabi/lib too * pivot to deleting stuff from the toolchain folder instead of selectively copying stuff. Starting with arm-none-eabi folder * Delete share folder instead * try deleting arm-none-eabi/lib * forgot the folder prefix * delete /lib/gcc/arm-none-eabi/13.3.1/arm and /lib/gcc/arm-none-eabi/13.3.1/thumb * delete all but v7-a+fp in thumb * forgot /arm-none-eabi-toolchain prefix again * remove files in RUN rm -f /arm-none-eabi-toolchain/lib/gcc/arm-none-eabi/13.3.1/* but not folders * Update Dockerfile * Update action.yml to test externally * Update Dockerfile with stages * fix copy from stage * comment out rm command to test stages * add back package installation * Update Dockerfile * refactor to have more stages * Update Dockerfile * Update build-image.yml * Update build-image.yml * Update build-image.yml * Remove line that deletes all 13.3.1 subfiles and subfolders * Diet some more files arm-none-eabi-cpp, arm-none-eabi-gdb, arm-none-eabi-gcc-13.3.1, * Change dieted files to their actual location (misread on my part) * Update Dockerfile * diet some more folders * we cut too much * Update build.sh * Update test.yml * revert back * revert back * Update action.yml * also remove gbd-py from toolchain bin folder * Update Dockerfile * re-add pros-cli * steal additional thumb deleting from jerryio's container * Update Dockerfile labels * Update Dockerfile * Thanks to @Jerrylum * Remove total build script runtime from build.sh as it's confusing * Delete packagelist * Update README.md * Update action.yml with v4.0.0 * remove pruning steps * Update build.sh to use shell instead of bash * remove bash * Restore bash * ♻️ Improved run instruction (#14) * ♻️ Improved run instruction - Makes it a little more readable by using heredoc - Pipes tar.xz to tar to prevent writing it to disk - Uses brace expansion where possible to shorten - Don't even write some of the unnecessary files to disk * split toolchain downloading into seperate RUN command for caching efficency and convert all tar --exclude params to their original rm/find forms. * Fix broken gcc rm command for /bin/arm-none-eabi-gcc-13.3.1 * fix gcc-13.3.1 removal * delete long_toolchain variable * 💄 Remove extra whitespace * remove package installation from get-dependencies since it's already redone in runner stage and the packages aren't used in the get-deps stage --------- Co-authored-by: ABUCKY0 <[email protected]> * Delete commented commands for clarity --------- Co-authored-by: Andrew Curtis <[email protected]>
1 parent 272e63b commit 1a3f11c

File tree

7 files changed

+55
-111
lines changed

7 files changed

+55
-111
lines changed

.github/workflows/build-image.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,4 @@ jobs:
209209
for tag in $(echo "${{ steps.load.outputs.tag }}" | tr ' ' '\n'); do
210210
echo "$tag"
211211
docker push "$tag"
212-
done
212+
done

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
with:
128128
name: "${{ steps.test-action.outputs.name }}${{ inputs.artifact_additional_postfix }}"
129129
path: "template/*"
130-
130+
131131
- name: Add Artifact to Job Summary
132132
if: ${{ inputs.upload_artifact && !inputs.expect_error }}
133133
run: 'echo "### 📦 Artifact url: ${{ steps.upload.outputs.artifact-url }}" >> $GITHUB_STEP_SUMMARY'

Dockerfile

+40-54
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,56 @@
1-
FROM ubuntu:20.04
1+
# ------------
2+
# Build Stage: Get Dependencies
3+
# ------------
4+
FROM alpine:latest AS get-dependencies
5+
LABEL stage=builder
26

37
LABEL org.opencontainers.image.description="A PROS Build Container"
48
LABEL org.opencontainers.image.source=https://github.com/lemlib/pros-build
59
LABEL org.opencontainers.image.licenses=MIT
6-
# ------------
7-
# Install Required Packages
8-
# ------------
9-
COPY packagelist /packagelist
10-
RUN apt-get update && apt-get install -y $(cat /packagelist) && apt-get clean
11-
RUN rm /packagelist # Cleanup Image
1210

13-
# ------------
14-
# Set Timezone and set frontend to noninteractive
15-
# ------------
16-
ENV DEBIAN_FRONTEND=noninteractive
17-
RUN echo "tzdata tzdata/Areas select America" | debconf-set-selections \
18-
&& echo "tzdata tzdata/Zones/America select Los_Angeles" | debconf-set-selections
11+
# Install Required Packages and ARM Toolchain
12+
RUN apk add --no-cache bash
13+
RUN mkdir "/arm-none-eabi-toolchain" && wget -O- "https://developer.arm.com/-/media/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi.tar.xz" \
14+
| tar Jxf - -C "/arm-none-eabi-toolchain" --strip-components=1
15+
RUN <<-"EOF" bash
16+
set -e
1917

20-
# ------------
21-
# Install ARM Toolchain
22-
# ------------
23-
RUN wget "https://developer.arm.com/-/media/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi.tar.xz" -O arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi.tar.xz
24-
RUN tar xf arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi.tar.xz
25-
RUN rm arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi.tar.xz # Cleanup Image
26-
RUN mv "/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi" "/arm-none-eabi-toolchain"
27-
ENV PATH="/arm-none-eabi-toolchain/bin:${PATH}"
18+
toolchain="/arm-none-eabi-toolchain"
19+
mkdir -p "$toolchain"
2820

29-
# ------------
30-
# Install PROS CLI
31-
# ------------
32-
RUN python3 -m pip install pros-cli
21+
rm -rf "$toolchain"/{share,include}
22+
rm -rf "$toolchain"/lib/gcc/arm-none-eabi/13.3.1/arm
23+
rm -f "$toolchain"/bin/arm-none-eabi-{gdb,gdb-py,cpp,gcc-13.3.1}
24+
25+
find "$toolchain"/arm-none-eabi/lib/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a+fp' -exec rm -rf {} +
26+
find "$toolchain"/lib/gcc/arm-none-eabi/13.3.1/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a+fp' -exec rm -rf {} +
27+
find "$toolchain"/arm-none-eabi/include/c++/13.3.1/arm-none-eabi/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a*' -exec rm -rf {} +
3328

29+
apk cache clean # Cleanup image
30+
EOF
3431
# ------------
35-
# Cleanup
36-
# ------------
37-
38-
# Cleanup APT
39-
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
40-
41-
# ------------
42-
# Verify Installation
43-
# ------------
44-
RUN python3 --version
45-
RUN pros --version
46-
RUN arm-none-eabi-g++ --version
47-
RUN arm-none-eabi-gcc --version
48-
49-
RUN git --version
50-
RUN make --version
51-
RUN unzip
52-
RUN awk --version
53-
54-
55-
# ------------
56-
# SETUP BUILD
32+
# Runner Stage
5733
# ------------
34+
FROM alpine:latest AS runner
35+
LABEL stage=runner
36+
LABEL org.opencontainers.image.description="A PROS Build Container"
37+
LABEL org.opencontainers.image.source=https://github.com/lemlib/pros-build
38+
LABEL org.opencontainers.image.licenses=MIT
39+
# Copy dependencies from get-dependencies stage
40+
COPY --from=get-dependencies /arm-none-eabi-toolchain /arm-none-eabi-toolchain
41+
RUN apk add --no-cache gcompat libc6-compat libstdc++ git gawk python3 pipx make unzip bash && pipx install pros-cli && apk cache clean
5842

59-
ENV PROS_PROJECT ${PROS_PROJECT}
60-
ENV REPOSITORY ${REPOSITORY}
61-
ENV LIBRARY_PATH ${LIBRARY_PATH}
43+
# Set Environment Variables
44+
ENV PATH="/arm-none-eabi-toolchain/bin:/root/.local/bin:${PATH}"
6245

63-
RUN env
6446

65-
COPY build-tools/build.sh .
66-
RUN chmod +x ./build.sh
47+
# Setup Build
48+
ENV PROS_PROJECT=${PROS_PROJECT}
49+
ENV REPOSITORY=${REPOSITORY}
50+
ENV LIBRARY_PATH=${LIBRARY_PATH}
6751

68-
COPY LICENSE .
52+
COPY build-tools/build.sh /build.sh
53+
RUN chmod +x /build.sh
54+
COPY LICENSE ./LICENSE
6955

7056
ENTRYPOINT ["/build.sh"]

README.md

+12-47
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
[![Build-Image action](https://github.com/LemLib/pros-build/actions/workflows/build-image.yml/badge.svg)](https://github.com/LemLib/pros-build/actions/workflows/build-image.yml)
44
[![Test action](https://github.com/LemLib/pros-build/actions/workflows/test.yml/badge.svg)](https://github.com/LemLib/pros-build/actions/workflows/test.yml)
55

6-
This action creates an environment capable of building PROS projects and templates, and builds them using [build.sh](/build-tools/build.sh)
6+
This action creates an environment capable of building PROS projects and templates and builds them using [build.sh](/build-tools/build.sh)
77

8-
Instructions on creating a custom build script, adding additional packages, and using this image as a base are located at the end of this readme.
8+
Instructions on creating a custom build script, adding additional packages, and using this image as a base are located at the end of this readme.
99

10+
> [!NOTE]
11+
> Also major thanks to [@JerryLum](https://github.com/jerrylum) for his gracious help and competition in building v4.0.0 to be as fast as it is now!
1012
## Usage:
1113

1214
### Inputs
@@ -62,7 +64,7 @@ jobs:
6264

6365
- name: Run LemLib/pros-build
6466
id: test
65-
uses: LemLib/pros-build@v3.0.0
67+
uses: LemLib/pros-build@v4.0.0
6668

6769
- name: Upload Artifact
6870
uses: actions/upload-artifact@v4
@@ -75,22 +77,16 @@ jobs:
7577
7678
If you wish to use your own build script using this container as a base, you can do so with the following:
7779
78-
It by default includes the packages built into the Ubuntu docker image, and contains the additional packages below:
80+
> [!WARNING]
81+
> The container now (v4.* and up) uses Alpine Linux and adds the necessary packages to build a PROS Project. The currently added package is listed below, but your mileage on using anything other than basic make commands in a pros project may vary wildly depending on how you create it.
82+
> We also trimmed the toolchain to be much smaller, so if you've modified your Makefile to use other features you may have to fork this repository and change what is removed from the toolchain.
7983
80-
```
81-
wget (Used to download the toolchain)
82-
git (Used to get the HEAD SHA hash)
83-
gawk (Used to get lines from the user project's Makefile)
84-
python3-minimal (Minimal installation of Python used for pros-cli)
85-
python3-pip (Used to install pros-cli in the Dockerfile)
86-
unzip (Unzips the template so that it can be uploaded to Github Actions)
87-
pros-cli (through python)
88-
```
84+
Installed Packages: `gcompat, libc6-compat, libstdc++, git, gawk, python3, pipx, make, unzip, bash`
8985

9086
### Editing the Dockerfile
9187

9288
```Dockerfile
93-
FROM ghcr.io/LemLib/pros-build:v3.0.0
89+
FROM ghcr.io/LemLib/pros-build:v4.0.0
9490
9591
# Remove the included build script.
9692
RUN rm -rf /build.sh
@@ -101,39 +97,8 @@ RUN rm -rf /build.sh
10197
ENTRYPOINT []
10298
```
10399

104-
# Example Job Summary Output
105-
106-
# ✅ Build Completed
107-
108-
Build completed in 25 seconds
109-
Total Build Script Runtime: 27 seconds
110-
111-
## 📝 Library Name: LemLib @ 0.5.1
112100

113-
### 🔐 SHA: 4f12f2
114-
115-
### 📁 Artifact Name: [email protected]+4f12f2
116-
117-
---
118-
119-
#### 📄 Output from Make
101+
# Example Job Summary Output
120102

121-
<details><summary>Click to expand</summary>
122-
```
123-
Creating bin/LemLib.a [DONE]
124-
Creating cold package with libpros,libc,libm,LemLib [OK]
125-
Stripping cold package [DONE]
126-
Section sizes:
127-
text data bss total hex filename
128-
1013.69KB 4.89KB 47.15MB 48.14MB 30234f7 bin/cold.package.elf
129-
Adding timestamp [OK]
130-
Linking hot project with ./bin/cold.package.elf and libpros,libc,libm,LemLib [OK]
131-
Section sizes:
132-
text data bss total hex filename
133-
3.97KB 12.00B 46.02MB 46.02MB 2e04a17 bin/hot.package.elf
134-
Creating cold package binary for VEX EDR V5 [DONE]
135-
Creating bin/hot.package.bin for VEX EDR V5 [DONE]
136-
```
137-
</details>
103+
![image](https://github.com/user-attachments/assets/a63ddfc0-5f14-44c0-8e1b-8902f1d99e55)
138104

139-
### 📦 Artifact url: https://github.com/LemLib/pros-build/actions/runs/9426610142/artifacts/1581443703

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ outputs:
3333

3434
runs:
3535
using: 'Docker'
36-
image: 'docker://ghcr.io/lemlib/pros-build:v3.0.0'
36+
image: 'docker://ghcr.io/lemlib/pros-build:v4.0.0'

build-tools/build.sh

-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ if [[ "$INPUT_WRITE_JOB_SUMMARY" == "true" ]]; then
200200
echo "
201201
# ✅ Build Completed
202202
Build completed in $build_time seconds
203-
Total Build Script Runtime: $(($SECONDS - $script_start_time)) seconds
204203
## 📝 Library Name: ${library_name} @ ${version}
205204
### 🔐 SHA: ${sha}
206205
" >>$GITHUB_STEP_SUMMARY

packagelist

-6
This file was deleted.

0 commit comments

Comments
 (0)