Skip to content

Commit

Permalink
feat: add justfile + containerfile for local build testing (#63)
Browse files Browse the repository at this point in the history
* feat: add justfile + containerfile for local build testing

* fix(just, containerfile): properly get build files

* feat(just): clean target
  • Loading branch information
tulilirockz authored Dec 12, 2024
1 parent a008744 commit 6f5e81d
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output/
21 changes: 21 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM registry.fedoraproject.org/fedora:latest AS builder
ARG TARGET_SPEC="${TARGET_SPEC:-staging/devpod/devpod.spec}"

COPY . /app

RUN dnf update -y && dnf upgrade -y && dnf install rpkg spectool -y && dnf clean all

WORKDIR /app
RUN cp -rf $(dirname $TARGET_SPEC)/* /tmp && \
rpkg --path $(dirname $TARGET_SPEC) spec --outdir /tmp --spec $(basename $TARGET_SPEC)

WORKDIR /tmp
RUN export SPEC=$(basename $TARGET_SPEC) && \
dnf -y builddep $SPEC && \
spectool -ag $SPEC -C /tmp && \
rpkg local --spec $SPEC --outdir /tmp && \
find /tmp

FROM scratch AS artifacts

COPY --from=builder /tmp/*/*.rpm /
41 changes: 41 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Run renovate locally to test modules
renovate dry-run="lookup" log-level="debug":
#!/usr/bin/env bash
if ! command -v "renovate" &> /dev/null ; then
echo "You need to install renovate first"
echo "It should be available on brew and on npm."
exit 1
fi
if [ "$GITHUB_COM_TOKEN" == "" ] ; then
echo "Warning: No Github token found, renovate will nag at you for this."
echo "Set it with GITHUB_COM_TOKEN=(your token)"
fi
LOG_LEVEL=${LOG_LEVEL:-debug} renovate --platform=local --dry-run={{dry-run}}
echo "Updates can be found in a section of the logs called \"packageFiles with updates\""
build package="staging/devpod/devpod.spec":
#!/usr/bin/env bash
PKGNAME={{package}}
PKGNAME="${PKGNAME##*/}"
PKGNAME="${PKGNAME%.*}"
buildah bud -f Containerfile -t localhost/${PKGNAME}:latest --build-arg TARGET_SPEC={{package}} .
extract package="staging/devpod/devpod.spec" extract_rpm="0":
#!/usr/bin/env bash
PKGNAME={{package}}
PKGNAME="${PKGNAME##*/}"
PKGNAME="${PKGNAME%.*}"
rm -rf output
mkdir -p output
podman export $(podman create localhost/${PKGNAME}:latest) | tar xf - -C output
if [ {{extract_rpm}} -ne 1 ] ; then
exit 0
fi
pushd output
for rpm_file in $(find . -iname "*.rpm"); do
rpm2cpio "$rpm_file" | cpio -idmv
done
popd
clean:
rm -rf output

0 comments on commit 6f5e81d

Please sign in to comment.