Skip to content

Commit

Permalink
Fixed image build action
Browse files Browse the repository at this point in the history
Signed-off-by: Janos SUTO <sj@acts.hu>
  • Loading branch information
jsuto committed Apr 14, 2024
1 parent 52eef82 commit c13432f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 42 deletions.
24 changes: 4 additions & 20 deletions .github/actions/build/image/action.yaml
@@ -1,8 +1,6 @@
name: 'Build image'

inputs:
ARCH:
required: true
DOCKER_USERNAME:
required: true
DOCKER_TOKEN:
Expand All @@ -14,16 +12,11 @@ inputs:
default: true
PACKAGE:
required: true
PLATFORMS:
required: true
PUSH:
required: false
default: false
TEST_TAG:
required: true

outputs:
IMAGE_NAME:
description: 'The built image'
value: ${{ steps.get-image-name.outputs.IMAGE_NAME }}

runs:
using: 'composite'
Expand All @@ -38,18 +31,9 @@ runs:
username: ${{ inputs.DOCKER_USERNAME }}
password: ${{ inputs.DOCKER_TOKEN }}

- name: Get built image name
id: get-image-name
run: |
IMAGE_NAME=${{ inputs.IMAGE_NAME }}:${{ inputs.TEST_TAG }}-${{ inputs.ARCH }}
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_OUTPUT
shell: bash

- name: Download package
uses: actions/download-artifact@v4
with:
name: package-${{ inputs.ARCH }}
path: docker

- name: Build image from package
Expand All @@ -58,7 +42,7 @@ runs:
context: docker
push: ${{ inputs.PUSH }}
load: ${{ inputs.LOAD }}
#tags: ${{ inputs.IMAGE_NAME }}:${{ inputs.TEST_TAG }}-${{ inputs.ARCH }}
tags: ${{ inputs.IMAGE_NAME }}:${{ inputs.ARCH }}
tags: ${{ inputs.IMAGE_NAME }}
platforms: ${{ inputs.PLATFORMS }}
build-args: |
PACKAGE=${{ inputs.PACKAGE }}
42 changes: 25 additions & 17 deletions .github/workflows/release.yaml
Expand Up @@ -6,13 +6,15 @@ on:
- piler*

env:
PROJECT_ID: piler
DISTRO: jammy
IMAGE_NAME: sutoj/piler

permissions:
contents: write

jobs:
build:
build-package:
strategy:
matrix:
arch: ['amd64','arm64']
Expand Down Expand Up @@ -40,40 +42,46 @@ jobs:
with:
ARCH: ${{ matrix.arch }}
COMMIT_ID: ${{ steps.get-version.outputs.COMMIT_ID }}
DISTRO: 'jammy'
IMAGE_NAME: ${{ env.IMAGE_NAME }}
DISTRO: ${{ env.DISTRO }}
IMAGE_NAME: ${{ env.IMAGE_NAME }}:${{ env.DISTRO }}-${{ matrix.arch }}
PROJECT_ID: 'piler'
VERSION: ${{ steps.get-version.outputs.VERSION }}

build-image:
needs:
- build-package

runs-on:
- self-hosted
- X64

steps:
- name: Download packages
uses: actions/download-artifact@v4
with:
path: docker
merge-multiple: true

- name: Build image
uses: ./.github/actions/build/image
with:
ARCH: ${{ matrix.arch }}
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
IMAGE_NAME: ${{ env.IMAGE_NAME }}
IMAGE_NAME: ${{ env.IMAGE_NAME }}:${{ needs.build-package.outputs.VERSION }}
LOAD: false
PACKAGE: ${{ steps.build-package.outputs.PACKAGE }}
PACKAGE: ${{ env.PROJECT_ID }}_${{ needs.build-package.outputs.VERSION }}-${{ env.DISTRO }}-${{ needs.build-package.outputs.COMMIT_ID }}
PLATFORMS: 'linux/amd64,linux/arm64'
PUSH: true
TEST_TAG: ${{ steps.get-version.outputs.VERSION }}

create-release:
needs:
- build
- build-image

runs-on:
- self-hosted
- X64

steps:
- name: Create docker manifest
run: |
set -x
docker manifest rm ${{ env.IMAGE_NAME }}:${{ needs.build.outputs.VERSION }} || true
docker manifest create ${{ env.IMAGE_NAME }}:${{ needs.build.outputs.VERSION }} --amend ${{ env.IMAGE_NAME }}:${{ needs.build.outputs.VERSION }}-amd64 --amend ${{ env.IMAGE_NAME }}:${{ needs.build.outputs.VERSION }}-arm64
docker manifest push ${{ env.IMAGE_NAME }}:${{ needs.build.outputs.VERSION }}
shell: bash

- name: Download packages
uses: actions/download-artifact@v4
with:
Expand Down
8 changes: 5 additions & 3 deletions docker/Dockerfile
@@ -1,6 +1,7 @@
FROM ubuntu:22.04

ARG PACKAGE
ARG TARGETARCH

LABEL description="piler ubuntu jammy image" \
maintainer="Janos SUTO, sj@acts.hu" \
Expand All @@ -11,8 +12,9 @@ ENV DEBIAN_FRONTEND="noninteractive" \
PILER_USER="piler" \
MYSQL_DATABASE="piler"

COPY ${PACKAGE} /
COPY ${PACKAGE}_${TARGETARCH}.deb /

# hadolint ignore=DL3008,DL3015
RUN apt-get update && \
apt-get -y --no-install-recommends install \
wget openssl sysstat php8.1-cli php8.1-cgi php8.1-mysql php8.1-fpm php8.1-zip php8.1-ldap \
Expand All @@ -26,10 +28,10 @@ RUN apt-get update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
sed -i '/session required pam_loginuid.so/c\#session required pam_loginuid.so' /etc/pam.d/cron && \
dpkg -i ${PACKAGE} && \
dpkg -i ${PACKAGE}_${TARGETARCH}.deb && \
touch /etc/piler/MANTICORE && \
ln -sf /etc/piler/piler-nginx.conf /etc/nginx/sites-enabled && \
rm -f ${PACKAGE} /etc/nginx/sites-enabled/default /etc/piler/piler.key /etc/piler/piler.pem /etc/piler/config-site.php && \
rm -f ${PACKAGE}_${TARGETARCH}.deb /etc/nginx/sites-enabled/default /etc/piler/piler.key /etc/piler/piler.pem /etc/piler/config-site.php && \
crontab -u $PILER_USER /usr/share/piler/piler.cron

VOLUME ["/etc/piler"]
Expand Down
4 changes: 2 additions & 2 deletions docker/README.md
Expand Up @@ -8,9 +8,9 @@ docker-compose up -d

## How to build the image for yourself

Pick the latest deb package from Bitbucket download page (https://bitbucket.org/jsuto/piler/downloads/)
Pick the latest deb package from Github releases (https://github.com/jsuto/piler/releases)
and use it as the PACKAGE build argument, eg.

```
docker build --build-arg PACKAGE=piler_1.4.1-jammy-c860ca67_amd64.deb -t piler:1.4.1 .
docker buildx build --load --platform linux/amd64 -t sutoj/piler:1.4.5 --build-arg PACKAGE=piler_1.4.5-jammy-ba34363 .
```

0 comments on commit c13432f

Please sign in to comment.