Skip to content

Commit

Permalink
Switch to using fpm for Debian package builds
Browse files Browse the repository at this point in the history
- Simplify the structure of the directories since we map included files
  in the fpm invocation
- Remove the DEBIAN directories and move control file values to fpm
  parameters in per-package build scripts
- Add VERSION files to each build directory as a simple way to update
  the version number manually or with automation
- Separate each package build to its own stage in order to normalize
  them and be able to target them individually for release
- Simplify the structure within the build containers to cut down on
  noise in the Dockerfile and use simple, conventional paths
- Add aggregation stage for collecting all packages from /debs/out
  • Loading branch information
botimer committed Jul 3, 2024
1 parent 7e5e80d commit 5f1040e
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 60 deletions.
46 changes: 31 additions & 15 deletions apache/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,42 @@ RUN meson configure -Dtests=true -Dintegration-tests=true && meson compile
CMD ["meson", "test", "-v"]

###
FROM build-base AS packages
FROM ruby:3.2.4 AS package-base

COPY ./apache/debpkgs /lauth/apache/debpkgs
WORKDIR /lauth/apache/debpkgs
RUN apt update && apt install -y --no-install-recommends binutils
RUN gem install fpm
RUN mkdir -p /debs/out
WORKDIR /debs

# http-check
COPY --from=module /lauth/apache/build/http-check /lauth/apache/debpkgs/http-check/usr/bin/
RUN ./package http-check
### http-check .deb
FROM package-base AS http-check
COPY ./apache/debpkgs/http-check .

# mod-authn-remoteuser
COPY --from=module /usr/lib/apache2/modules/mod_authn_remoteuser.so /lauth/apache/debpkgs/mod-authn-remoteuser/usr/lib/apache2/modules/
RUN ./package mod-authn-remoteuser
COPY --from=module /lauth/apache/build/http-check .
RUN ./build && mv *.deb *.changes out/

# mod-lauth
COPY --from=module /usr/local/ /lauth/apache/debpkgs/mod-lauth/usr/
COPY --from=module /usr/lib/apache2/modules/mod_lauth.so /lauth/apache/debpkgs/mod-lauth/usr/lib/apache2/modules/
RUN ./package mod-lauth
### mod-authn-remoteuser .deb
FROM package-base AS mod-authn-remoteuser
COPY ./apache/debpkgs/mod-authn-remoteuser .

# Docker Compose Volume Mapping Directory
COPY ./apache/packages /lauth/apache/packages
COPY --from=module /usr/lib/apache2/modules/mod_authn_remoteuser.so .
RUN ./build && mv *.deb *.changes out/

### mod-lauth .deb
FROM package-base AS mod-lauth
COPY ./apache/debpkgs/mod-lauth .

COPY --from=module /usr/lib/apache2/modules/mod_lauth.so .
RUN ./build && cp *.deb *.changes out/

###
FROM package-base AS packages
WORKDIR /debs/out

COPY --from=http-check /debs/out/* .
COPY --from=mod-authn-remoteuser /debs/out/* .
COPY --from=mod-lauth /debs/out/* .
CMD ["ls", "-la"]

##
FROM debian:bullseye-slim AS server
Expand Down
8 changes: 0 additions & 8 deletions apache/debpkgs/http-check/DEBIAN/control

This file was deleted.

1 change: 1 addition & 0 deletions apache/debpkgs/http-check/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1
17 changes: 17 additions & 0 deletions apache/debpkgs/http-check/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

if [ ! -f "VERSION" ]; then
echo "VERSION file is missing!"
exit -1
fi

fpm --input-type dir \
--output-type deb \
--architecture native \
--deb-generate-changes \
\
--name http-check \
--version "$(<VERSION)" \
--maintainer 'University of Michigan Library Information Technology' \
--description 'Health Check for Apache2' \
http-check=/usr/bin/http-check
8 changes: 0 additions & 8 deletions apache/debpkgs/mod-authn-remoteuser/DEBIAN/control

This file was deleted.

1 change: 1 addition & 0 deletions apache/debpkgs/mod-authn-remoteuser/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1
19 changes: 19 additions & 0 deletions apache/debpkgs/mod-authn-remoteuser/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

if [ ! -f "VERSION" ]; then
echo "VERSION file is missing!"
exit -1
fi

fpm --input-type dir \
--output-type deb \
--architecture native \
--deb-generate-changes \
\
--name libapache2-mod-authn-remoteuser \
--version "$(<VERSION)" \
--depends apache2 \
--maintainer 'University of Michigan Library Information Technology' \
--description 'Fake Remote User Authentication Module for Apache2' \
conf=/etc/apache2/mods-available \
mod_authn_remoteuser.so=/usr/lib/apache2/modules/mod_authn_remoteuser.so
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# Depends:
LoadModule authn_remoteuser_module /usr/lib/apache2/modules/mod_authn_remoteuser.so
8 changes: 0 additions & 8 deletions apache/debpkgs/mod-lauth/DEBIAN/control

This file was deleted.

1 change: 1 addition & 0 deletions apache/debpkgs/mod-lauth/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.8
20 changes: 20 additions & 0 deletions apache/debpkgs/mod-lauth/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

if [ ! -f "VERSION" ]; then
echo "VERSION file is missing!"
exit -1
fi

fpm --input-type dir \
--output-type deb \
--architecture native \
--deb-generate-changes \
\
--name libapache2-mod-lauth \
--version "$(<VERSION)" \
--depends apache2 \
--after-install postinst \
--maintainer 'University of Michigan Library Information Technology' \
--description 'Fake Remote User Authentication Module for Apache2' \
conf=/etc/apache2/mods-available \
mod_lauth.so=/usr/lib/apache2/modules/mod_lauth.so
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# Depends:
LoadModule lauth_module /usr/lib/apache2/modules/mod_lauth.so
File renamed without changes.
18 changes: 0 additions & 18 deletions apache/debpkgs/package

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ services:
restart: "no"
volumes:
- ./apache/packages:/lauth/apache/packages
command: ["sh", "-c", "cp *.deb /lauth/apache/packages"]
command: ["sh", "-c", "cp *.deb *.changes /lauth/apache/packages"]

mock-api:
profiles: [ "test", "integration" ]
Expand Down

0 comments on commit 5f1040e

Please sign in to comment.