Skip to content

Commit

Permalink
Use new base container & push directly to quay.io
Browse files Browse the repository at this point in the history
This commit should solve once and for all the problems related to the container
cache, since with this the build now happens on GitHub Actions.
We now use the base container kpa-marp-pandoc [1] that covers all KPA needed
tools and dependencies, and let us prepare the new container with an improved
speed and lightness.

[1] https://github.com/mmul-it/kpa-marp-pandoc

Fixes #8
  • Loading branch information
rascasoft committed Aug 2, 2023
1 parent 8dfeea9 commit 34109dc
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 72 deletions.
59 changes: 26 additions & 33 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
name: Create PDFs for example project
name: Linter, test, build and push KPA container

env:
KPA_PROJECT: example
REGISTRY_NAME: quay.io
CONTAINER_NAME: mmul/kpa
CONTAINER_VERSION: latest

on: [push]

jobs:
lint:
linter:
runs-on: ubuntu-latest
container:
image: quay.io/mmul/kpa
options: --user root
image: quay.io/mmul/kpa-marp-pandoc
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -25,54 +27,45 @@ jobs:
- name: Check markdown files for example project
run: mdl projects/${KPA_PROJECT}/contents/*.md

markdown:
test:
runs-on: ubuntu-latest
container:
image: quay.io/mmul/kpa
options: --user root
needs: lint
image: quay.io/mmul/kpa-marp-pandoc
needs: linter
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Ansible requirements
run: ansible-galaxy install
-r playbooks/roles/requirements.yml
--roles-path ./playbooks/roles
- name: Generate markdown files
run: for TRAINING in $(ls projects/${KPA_PROJECT}/*.yml); do
- name: Generate markdown and pdf files
run: for KPA_DOC in $(ls projects/${KPA_PROJECT}/*.yml); do
echo "Processing ${TRAINING}";
ansible-playbook
-e @projects/${KPA_PROJECT}/common/settings.yml
-e @${TRAINING}
-e @${KPA_DOC}
playbooks/kpa_generator.yml;
done
- name: Upload markdown files
- name: Upload generated markdown files
uses: actions/upload-artifact@v3
with:
name: markdowns
path: output/**.md

marp-pdf:
runs-on: ubuntu-latest
container:
image: quay.io/mmul/kpa
options: --user root
needs: markdown
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download markdown files
uses: actions/download-artifact@v3
with:
name: markdowns
path: output/
- name: Generate Marp pdf files
run: for TRAINING in $(ls output/*.md); do
echo "Processing ${TRAINING}";
marp --theme projects/${KPA_PROJECT}/common/theme.css --html --pdf --allow-local-files ${TRAINING};
done
- name: Upload Marp pdf files
- name: Upload generated pdf files
uses: actions/upload-artifact@v3
with:
name: pdfs
path: output/**.pdf

build_and_push:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v3
- name: Build the container image
run: docker build . --file Dockerfile --tag ${REGISTRY_NAME}/${CONTAINER_NAME}:${CONTAINER_VERSION}
- name: Login into the container registry
run: docker login -u="${{ vars.QUAY_ROBOT_NAME }}" -p="${{ secrets.QUAY_ROBOT_TOKEN }}" ${REGISTRY_NAME}
- name: Push the image into the container registry
run: docker push ${REGISTRY_NAME}/${CONTAINER_NAME}:${CONTAINER_VERSION}
51 changes: 13 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,46 +1,22 @@
# Containerfile for KPA project to be used in CI
# Dockerfile for KPA project to be used in CI

# Start from ansible-core
FROM docker.io/ubuntu:22.04
FROM quay.io/mmul/kpa-marp-pandoc

# Update repo contents
RUN apt update
# Create workdir path
RUN mkdir /kpa
RUN mkdir /kpa/output
RUN mkdir /kpa/projects

# Install requiremets
RUN apt -y install python3-pip curl git

# Upgrade pip & install ansible & ansible-lint
RUN pip3 install --upgrade pip && \
pip3 install ansible ansible-lint

# Install yamllint
RUN pip3 install yamllint

# Install mdl (Mardownlinter)
RUN apt -y install rubygems
RUN gem install mdl

# Install Marp with nodejs and chrome
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list && \
curl -s https://dl.google.com/linux/linux_signing_key.pub -o - | apt-key add - && \
gpg --refresh-keys && \
apt update
RUN apt -y install nodejs google-chrome-stable
RUN npm install -g @marp-team/marp-cli

# Install pandoc with texlive
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC
RUN apt -y install pandoc texlive texlive-base texlive-binaries \
texlive-fonts-recommended texlive-latex-base texlive-latex-extra \
texlive-latex-recommended texlive-pictures texlive-plain-generic texlive-xetex
# Copy local files into container
COPY kpa.sh /kpa/
COPY playbooks /kpa/playbooks
COPY projects/example /kpa/projects/example

# Add user and group for the kpa unprivileged user
RUN groupadd --gid 1000 kpa && \
useradd --no-log-init -d /kpa --uid 1000 -g kpa kpa && \
mkdir /kpa && \
chown -R kpa: /kpa
RUN groupadd --gid 1000 kpa
RUN useradd --no-log-init -d /kpa --uid 1000 -g kpa kpa
RUN chown -R kpa: /kpa

# Set /kpa as workdir
WORKDIR /kpa
Expand All @@ -49,7 +25,6 @@ WORKDIR /kpa
USER kpa

# Install KPA repository
RUN git clone https://github.com/mmul-it/kpa .
RUN ansible-galaxy install \
-r playbooks/roles/requirements.yml \
--roles-path ./playbooks/roles
Expand Down
2 changes: 1 addition & 1 deletion playbooks/kpa_generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
connection: local
gather_facts: false
tasks:
- name: Import KPA Marp slides generator role
- name: Import KPA generator role
ansible.builtin.import_role:
name: mmul.kpa_generator

0 comments on commit 34109dc

Please sign in to comment.