From f2a58a53aca903c870f235ba0a20e8c07b19b6ef Mon Sep 17 00:00:00 2001 From: Nik Gupta Date: Mon, 9 Dec 2024 17:03:17 +0000 Subject: [PATCH] [WIP] Add package for FMS build artefacts. --- packages/fms-base/.gitignore | 4 ++++ packages/fms-base/bin/.gitkeep | 0 packages/fms-base/conf/Dockerfile.j2 | 33 +++++++++++++++++++++++++++ packages/fms-base/conf/Makefile.j2 | 34 ++++++++++++++++++++++++++++ packages/fms-base/conf/conf.yaml | 8 +++++++ packages/fms-base/configure | 5 ++++ packages/fms-base/deb/.gitkeep | 0 7 files changed, 84 insertions(+) create mode 100644 packages/fms-base/.gitignore create mode 100644 packages/fms-base/bin/.gitkeep create mode 100644 packages/fms-base/conf/Dockerfile.j2 create mode 100644 packages/fms-base/conf/Makefile.j2 create mode 100644 packages/fms-base/conf/conf.yaml create mode 100755 packages/fms-base/configure create mode 100644 packages/fms-base/deb/.gitkeep diff --git a/packages/fms-base/.gitignore b/packages/fms-base/.gitignore new file mode 100644 index 0000000..95bfc14 --- /dev/null +++ b/packages/fms-base/.gitignore @@ -0,0 +1,4 @@ +/Dockerfile* +/Makefile +bin/build.sh +bin/configure.py diff --git a/packages/fms-base/bin/.gitkeep b/packages/fms-base/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/packages/fms-base/conf/Dockerfile.j2 b/packages/fms-base/conf/Dockerfile.j2 new file mode 100644 index 0000000..26e7899 --- /dev/null +++ b/packages/fms-base/conf/Dockerfile.j2 @@ -0,0 +1,33 @@ +FROM base-builder:{{ codename }}-latest +LABEL maintainer="{{ vendor}} <{{ vendor_email }}>" + +RUN apt-get -qq update && apt-get -qq -y install git perl postgresql + +WORKDIR /home/builder +USER builder + +ARG TAG={{ version }} +RUN git clone --recursive https://github.com/mysociety/fixmystreet.git + +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 fpm -s dir -t deb \ + --vendor "mySociety" \ + --maintainer "mySociety " \ + --version "{{ version }}" \ + --iteration "ms1" \ + --architecture "all" \ + --url "https://github.com/mysociety/fixmystreet" \ + --description "mysociety's package containing build artefacts to speed up the process of deploying new FixMyStreet servers." \ + -n "fms-base" \ + ./local/=/data/fms_deps/perl_modules + +CMD ["sh", "-c", "/bin/mv *.deb ../deb/{{ codename }}"] diff --git a/packages/fms-base/conf/Makefile.j2 b/packages/fms-base/conf/Makefile.j2 new file mode 100644 index 0000000..abefb78 --- /dev/null +++ b/packages/fms-base/conf/Makefile.j2 @@ -0,0 +1,34 @@ +.PHONEY: all +{% if shared_package %} +all: build + +build: + @./bin/build.sh + +{% else %} +all: {{ codenames | join(' ') }} + +{% for codename in codenames %} +.PHONEY: {{ codename }} +{{ codename }}: + @echo "==> Building {{ codename }}..." + @./bin/build.sh {{ codename }} + +{% endfor %} +{% endif %} + +.PHONEY: clean-deb clean-images clean-config clean +clean-deb: + @echo "==> Removing old artefacts..." + @rm -fr deb/* || echo "==> No artefacts found." + +clean-images: + @echo "==> Removing old Docker images..." + @docker image ls -q $(shell basename $(shell pwd))-builder | xargs docker rmi -f 2>/dev/null || echo "==> No images found." + +clean-config: + @echo "==> Cleaning up locally generated config..." + @rm -f Dockerfile* + @rm -f Makefile + +clean: clean-deb clean-images clean-config diff --git a/packages/fms-base/conf/conf.yaml b/packages/fms-base/conf/conf.yaml new file mode 100644 index 0000000..6150818 --- /dev/null +++ b/packages/fms-base/conf/conf.yaml @@ -0,0 +1,8 @@ +--- +iteration: ms1 +version: 6.0 +skip_codenames: + - buster + - bionic + - focal + - jammy diff --git a/packages/fms-base/configure b/packages/fms-base/configure new file mode 100755 index 0000000..38bfd9e --- /dev/null +++ b/packages/fms-base/configure @@ -0,0 +1,5 @@ +#!/bin/sh + +[ -f ../../.venv/packaging/bin/activate ] && . ../../.venv/packaging/bin/activate + +./bin/configure.py diff --git a/packages/fms-base/deb/.gitkeep b/packages/fms-base/deb/.gitkeep new file mode 100644 index 0000000..e69de29