This repository has been archived by the owner on May 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
202 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Build system provisioning | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 360 # default 6 hour | ||
env: | ||
TZ: Asia/Tokyo | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v4.0.0 | ||
|
||
- name: "get openwrt version from Dockerfile" | ||
run: | | ||
set -eux | ||
OPENWRT_VERSION=$(grep -oP '(?<=OPENWRT_VERSION=").+(?=")' Dockerfile) | ||
if [ -z "$OPENWRT_VERSION" ]; then | ||
exit 1 | ||
fi | ||
echo "OPENWRT_VERSION=${OPENWRT_VERSION}" >> $GITHUB_ENV | ||
- uses: docker/metadata-action@v5 | ||
id: meta | ||
with: | ||
images: ghcr.io/${{ github.repository }}/build-system | ||
tags: | | ||
# set latest tag for default branch | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
# OpenWrt version tag | ||
type=raw,value=${{ env.OPENWRT_VERSION }},enable={{is_default_branch}} | ||
- name: Build and push | ||
uses: docker/build-push-action@v5.0.0 | ||
with: | ||
push: true | ||
cache-from: type=gha,scope=build-system-${{ env.OPENWRT_VERSION }} | ||
cache-to: type=gha,mode=max,scope=build-system-${{ env.OPENWRT_VERSION }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
FROM ubuntu:22.04 as build-base | ||
|
||
ARG \ | ||
BUILD_USERNAME="builder" \ | ||
DEBIAN_FRONTEND="noninteractive" \ | ||
OPENWRT_VERSION="v23.05.2" | ||
|
||
LABEL version="0.0.1" | ||
LABEL description="A working container for building OpenWrt" | ||
LABEL repository="https://github.com/naa0yama/OpenWrt-FortiGate-50E-custom-image" | ||
|
||
#- ----------------------------------------------------------------------------- | ||
#- - Base | ||
#- ----------------------------------------------------------------------------- | ||
# Build system setup | ||
# Ref: https://openwrt.org/docs/guide-developer/toolchain/install-buildsystem | ||
RUN set -eux \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
clang \ | ||
flex \ | ||
bison \ | ||
g++ \ | ||
gawk \ | ||
gcc-multilib \ | ||
g++-multilib \ | ||
gettext \ | ||
git \ | ||
libncurses-dev \ | ||
libssl-dev \ | ||
python3-distutils \ | ||
rsync \ | ||
unzip \ | ||
zlib1g-dev \ | ||
file \ | ||
wget \ | ||
ca-certificates \ | ||
libcurl4-openssl-dev \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Debug settings | ||
RUN set -eux \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
bash \ | ||
sudo \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& useradd -m "${BUILD_USERNAME}" \ | ||
&& mkdir -p /etc/sudoers.d \ | ||
&& echo "${BUILD_USERNAME} ALL=NOPASSWD: ALL" > "/etc/sudoers.d/${BUILD_USERNAME}" | ||
|
||
# Set git patching | ||
RUN set -eux \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
apt-transport-https \ | ||
ca-certificates \ | ||
curl \ | ||
software-properties-common \ | ||
gpg-agent \ | ||
&& add-apt-repository -y -u ppa:git-core/ppa \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends git \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& git --version --build-options | ||
|
||
# gitconfig global | ||
RUN set -eux \ | ||
&& git config --global user.name "user" \ | ||
&& git config --global user.email "user@example.com" \ | ||
&& git config --global http.postBuffer 500M \ | ||
&& git config --global https.postBuffer 500M | ||
|
||
USER ${BUILD_USERNAME} | ||
WORKDIR "/home/${BUILD_USERNAME}" | ||
|
||
|
||
#- ----------------------------------------------------------------------------- | ||
#- - Preparing the source code | ||
#- ----------------------------------------------------------------------------- | ||
# Build system usage | ||
# Ref: https://openwrt.org/docs/guide-developer/toolchain/use-buildsystem | ||
FROM build-base as runner | ||
|
||
# Download and update the sources | ||
RUN set -eux \ | ||
&& git clone --verbose --progress --depth 1 --branch "${OPENWRT_VERSION}" \ | ||
https://github.com/openwrt/openwrt.git \ | ||
&& cd openwrt | ||
|
||
# # # Update the feeds | ||
WORKDIR "/home/${BUILD_USERNAME}/openwrt" | ||
RUN set -eux \ | ||
&& sed -i'' -e 's@git.openwrt.org/feed@github.com/openwrt@g' ./feeds.conf.default \ | ||
&& sed -i'' -e 's@git.openwrt.org/project@github.com/openwrt@g' ./feeds.conf.default \ | ||
&& cat ./feeds.conf.default \ | ||
&& ./scripts/feeds update -a \ | ||
&& ./scripts/feeds install -a | ||
|
||
#- ----------------------------------------------------------------------------- | ||
#- - Runner | ||
#- ----------------------------------------------------------------------------- | ||
FROM runner | ||
|
||
COPY --chown=${BUILD_USERNAME}:${BUILD_USERNAME} \ | ||
config/mvebu-cortexa9-fortinet_fg-50e.ini "/home/${BUILD_USERNAME}/openwrt/.config" | ||
RUN set -eux \ | ||
&& make defconfig \ | ||
&& make --directory ./ -j $(($(nproc)+1)) download world \ | ||
&& rm -rf openwrt/bin/targets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters