Skip to content

Commit

Permalink
Merge pull request #79 from mlibrary/use-fpm-for-debs
Browse files Browse the repository at this point in the history
Use fpm for debs and export build artifact
  • Loading branch information
botimer authored Jul 4, 2024
2 parents 59c3b76 + 73b3833 commit 1fc9f99
Show file tree
Hide file tree
Showing 18 changed files with 132 additions and 61 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build-apache-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,26 @@ jobs:
push: true
tags: 'ghcr.io/mlibrary/lauth/lauth-apache:${{ github.sha }}, ghcr.io/mlibrary/lauth/lauth-apache:latest'
file: ./apache/Dockerfile

- name: Build .deb packages
uses: docker/build-push-action@v5
with:
context: ./
target: packages
push: false
load: true
tags: 'lauth-debs:latest'
file: ./apache/Dockerfile

- uses: shrink/actions-docker-extract@v3
id: extract
with:
image: lauth-debs:latest
path: /debs/out/.
destination: dist

- name: Archive lauth-apache .deb packages
uses: actions/upload-artifact@v4
with:
name: lauth-apache-debs_${{ github.sha }}
path: dist/*
49 changes: 33 additions & 16 deletions apache/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,43 @@ 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/local/lib ./lib
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 All @@ -75,7 +92,7 @@ RUN apt update; \
RUN a2enmod authz_groupfile cgid headers proxy proxy_http remoteip rewrite

# install debian packages: http-check, mod-authn-remoteuser, mod-lauth
COPY --from=packages /lauth/apache/debpkgs/*.deb /tmp
COPY --from=packages /debs/out/*.deb /tmp
RUN dpkg -i /tmp/*.deb
RUN rm -f /tmp/*.deb

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
21 changes: 21 additions & 0 deletions apache/debpkgs/http-check/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/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 \
\
--deb-dist bullseye \
\
--name http-check \
--version "$(<VERSION)" \
--url 'https://github.com/mlibrary/lauth' \
--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
23 changes: 23 additions & 0 deletions apache/debpkgs/mod-authn-remoteuser/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/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 \
\
--deb-dist bullseye \
--depends apache2 \
\
--name libapache2-mod-authn-remoteuser \
--version "$(<VERSION)" \
--url 'https://github.com/mlibrary/lauth' \
--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
28 changes: 28 additions & 0 deletions apache/debpkgs/mod-lauth/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/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 \
\
--deb-dist bullseye \
--depends apache2 \
--depends libstdc++6 \
--depends libssl1.1 \
--exclude 'usr/lib/python3.9' \
\
--name libapache2-mod-lauth \
--version "$(<VERSION)" \
--after-install postinst \
--url 'https://github.com/mlibrary/lauth' \
--maintainer 'University of Michigan Library Information Technology' \
--description 'Library Authentication/Authorization Module for Apache2' \
\
conf/=/etc/apache2/mods-available \
lib/=/usr/lib \
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 1fc9f99

Please sign in to comment.