From 3724b5cf5088aadd7eaf6656e3a67150f6b5eddb Mon Sep 17 00:00:00 2001 From: Nik Gupta Date: Mon, 24 Feb 2025 22:03:18 +0000 Subject: [PATCH] Add action to build FMS packages. --- .github/workflows/fms-base.yml | 54 ++++++++++++++++++++++++++++ images/base/conf/Dockerfile.j2 | 2 +- packages/fms-base/conf/Dockerfile.j2 | 8 +++-- script/bootstrap | 28 +++++++-------- template/bin/build.sh | 1 + 5 files changed, 75 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/fms-base.yml diff --git a/.github/workflows/fms-base.yml b/.github/workflows/fms-base.yml new file mode 100644 index 0000000..48d481b --- /dev/null +++ b/.github/workflows/fms-base.yml @@ -0,0 +1,54 @@ +name: build-fms-base + +on: + push: + +jobs: + build: + strategy: + max-parallel: 1 + matrix: + debian_release: ['bullseye', 'bookworm'] + arch: ['amd64', 'arm64'] + + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.9.1' + + # See: https://docs.docker.com/build/ci/github-actions/multi-platform/#build-and-load-multi-platform-images + - name: Set up Docker + uses: docker/setup-docker-action@v4 + with: + daemon-config: | + { + "features": { + "containerd-snapshotter": true, + "debug": true + } + } + + - name: Repo setup + run: ./script/update + + - name: Build base + run: | + cd images/base + make ${{ matrix.debian_release }}-${{ matrix.arch }} + + - name: Build package + run: | + cd packages/fms-base + sudo chmod -R 777 ./deb + make ${{ matrix.debian_release }}-${{ matrix.arch }} + + - name: Archive packages + uses: actions/upload-artifact@v4 + with: + name: packages + path: packages/fms-base/deb/${{ matrix.debian_release }}/*.deb diff --git a/images/base/conf/Dockerfile.j2 b/images/base/conf/Dockerfile.j2 index cc3514c..95e38b3 100644 --- a/images/base/conf/Dockerfile.j2 +++ b/images/base/conf/Dockerfile.j2 @@ -16,7 +16,7 @@ RUN apt-get update -qq \ lsb-release \ ruby-dev \ wget \ - --no-install-recommends > /dev/null \ + --no-install-recommends \ && apt-get install -qq {% if codename == "bionic" %} -t {{ codename }}-backports {% endif %} debhelper \ && rm -r /var/lib/apt/lists/* diff --git a/packages/fms-base/conf/Dockerfile.j2 b/packages/fms-base/conf/Dockerfile.j2 index 59f746d..96e9a7e 100644 --- a/packages/fms-base/conf/Dockerfile.j2 +++ b/packages/fms-base/conf/Dockerfile.j2 @@ -12,16 +12,17 @@ USER builder ARG TAG={{ version }} RUN git clone --recursive https://github.com/mysociety/fixmystreet.git -RUN git checkout v{{ version }} WORKDIR /home/builder/fixmystreet +RUN git checkout v{{ version }} USER root RUN cp conf/packages.docker /opt/ RUN xargs -a "/opt/packages.docker" apt-get -qq -y install >/dev/null USER builder -RUN ./script/bootstrap +#RUN ./script/bootstrap +run mkdir local RUN fpm -s dir -t deb \ --vendor "mySociety" \ --maintainer "mySociety " \ @@ -33,4 +34,5 @@ RUN fpm -s dir -t deb \ -n "fms-base" \ ./local/=/data/fms_deps/perl_modules -CMD ["sh", "-c", "/bin/mv *.deb ../deb/{{ codename }}"] +#CMD ["/bin/mv *.deb ../deb/{{ codename }}"] +CMD ls -la . && ls -la ../deb && mv *.deb ../deb diff --git a/script/bootstrap b/script/bootstrap index 4ba9bab..7c704b8 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -4,21 +4,21 @@ set -e cd "$(dirname "$0")/.." -WANTED_PYTHON=$(cat .python-version) +#WANTED_PYTHON=$(cat .python-version) -if command -v pyenv >/dev/null ; then - echo "==> Found pyenv..." - if [ -z "$(pyenv version-name 2>/dev/null)" ] ; then - echo "==> Installing Python ${WANTED_PYTHON} via pyenv..." - pyenv install --skip-existing - fi -else - echo "==> Not found pyenv, checking available python version..." - if [ "$(python3 --version | awk '{ $NF }')" != "$WANTED_PYTHON" ] ; then - echo "==> We require ${WANTED_PYTHON}. Fix that, and run me again." - exit 1 - fi -fi +#if command -v pyenv >/dev/null ; then + #echo "==> Found pyenv..." + #if [ -z "$(pyenv version-name 2>/dev/null)" ] ; then + #echo "==> Installing Python ${WANTED_PYTHON} via pyenv..." + #pyenv install --skip-existing + #fi +#else + #echo "==> Not found pyenv, checking available python version..." + #if [ "$(python3 --version | awk '{ $NF }')" != "$WANTED_PYTHON" ] ; then + #echo "==> We require ${WANTED_PYTHON}. Fix that, and run me again." + #exit 1 + #fi +#fi VIRTUALENV=".venv/packaging" if [ ! -f "${VIRTUALENV}/bin/activate" ] ; then diff --git a/template/bin/build.sh b/template/bin/build.sh index b2b2354..4c9f3bf 100755 --- a/template/bin/build.sh +++ b/template/bin/build.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -xo DIST=${1:-all} ARCH=${2:-none}