Skip to content

Commit

Permalink
refactor: rewrite to dockerfile
Browse files Browse the repository at this point in the history
Signed-off-by: Wesley Gimenes <wehagy@proton.me>
  • Loading branch information
wehagy committed Sep 16, 2024
1 parent fd957db commit a2f584e
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 29 deletions.
43 changes: 14 additions & 29 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,18 @@ on:
jobs:
build-openwrt-image:
runs-on: ubuntu-24.04
container:
image: quay.io/containers/podman:v5.2
options: --privileged

strategy:
fail-fast: false
matrix:
image:
# W
- "x86 64 generic"
- "ath79 generic tplink_archer-c7-v4"
- "mediatek filogic xiaomi_mi-router-ax3000t-ubootmod"
# P
- "ramips mt7621 totolink_x5000r"
- "mediatek filogic bananapi_bpi-r3"
# strategy:
# fail-fast: false
# matrix:
# image:
# # W
# - "x86 64 generic"
# - "ath79 generic tplink_archer-c7-v4"
# - "mediatek filogic xiaomi_mi-router-ax3000t-ubootmod"
# # P
# - "ramips mt7621 totolink_x5000r"
# - "mediatek filogic bananapi_bpi-r3"

steps:
- name: Checkout repo from main if run from compare-release
Expand All @@ -44,24 +41,12 @@ jobs:

- name: Build image
run: |
dnf \
--refresh \
--assumeyes \
--nodocs \
--setopt=install_weak_deps=False \
upgrade
dnf \
--assumeyes \
--nodocs \
--setopt=install_weak_deps=False \
install \
quilt
podman info
./openwrt-builder.sh ${{ matrix.image }}
docker build --rm --output openwrt .
- name: Prepare artifact name
run: |
echo "artifact_name=$(t="${{ matrix.image }}" && echo "${t##* }")" >> "$GITHUB_ENV"
echo "openwrt-x86"
#echo "artifact_name=$(t="${{ matrix.image }}" && echo "${t##* }")" >> "$GITHUB_ENV"
- name: Upload openwrt image artifacts
uses: actions/upload-artifact@v4
Expand Down
87 changes: 87 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
FROM ghcr.io/openwrt/sdk:x86-64-main AS sdk-stage

COPY --chown=buildbot /custom-feed/ ./custom-feed/
COPY --chown=buildbot /patches/ ./patches/

USER root
RUN <<EOF
apt update
apt install -y quilt
EOF

USER buildbot
COPY --chmod=755 <<"EOF" build.sh
#!/usr/bin/env bash

set -eux

quilt push -a
sed \
--in-place \
--regexp-extended \
's,git\.openwrt\.org\/(openwrt|feed|project),github\.com\/openwrt,' \
feeds.conf.default
sed \
--in-place \
'1i src-link custom /builder/custom-feed' \
feeds.conf.default
./scripts/feeds update -a
make defconfig

for PACKAGE in custom-feed/*; do
./scripts/feeds install "${PACKAGE##*/}"
make package/"${PACKAGE##*/}"/{clean,compile} \
V=s \
-j"$(nproc)"
done
EOF
RUN ./build.sh



FROM sdk-stage AS sdk-packages-stage
COPY --chmod=755 <<"EOF" build.sh
#!/usr/bin/env bash

set -eux

rm -rf bin/targets/
rmdir bin/packages/*/custom/tmp
shopt -s extglob
rm -rf bin/packages/*/!(custom)
shopt -u extglob

mkdir packages
shopt -s globstar nullglob
for IPK in bin/**/custom/*.ipk; do
cp "${IPK}" packages/
done
shopt -u globstar nullglob
EOF
RUN ./build.sh



FROM ghcr.io/openwrt/imagebuilder:x86-64-main AS imagebuilder-stage

ENV PROFILE_IMAGE="${PROFILE_IMAGE:-generic}"
ENV PACKAGES_IMAGE="${PACKAGES_IMAGE:-luci luci-ssl}"
COPY --from=sdk-packages-stage --chown=buildbot /builder/packages/* /builder/packages/
COPY --chmod=755 <<"EOF" build.sh
#!/usr/bin/env bash

set -eux

PACKAGES_IMAGE+=("$(basename -a packages/*.ipk | cut -d '_' -f 1)")

make image PROFILE=${PROFILE_IMAGE} PACKAGES="${PACKAGES_IMAGE[*]}" \
V=s \
-j"$(nproc)"
EOF
RUN ./build.sh



FROM scratch AS export-stage
COPY --from=sdk-packages-stage /builder/bin/ .
COPY --from=imagebuilder-stage /builder/bin/ .

0 comments on commit a2f584e

Please sign in to comment.