Skip to content

Commit

Permalink
global: build base images
Browse files Browse the repository at this point in the history
  • Loading branch information
mb-wali committed Dec 4, 2024
1 parent 6118f22 commit 0a86782
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: build and push docker image

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

on:
push:
branches:
- main
workflow_dispatch:

jobs:

build-publish-frontend:
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: Dockerfile.frontend
push: true
tags: ${{ steps.meta.outputs.tags }}-frontend
labels: ${{ steps.meta.outputs.labels }}-frontend

build-publish-builder:
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: Dockerfile.builder
push: true
tags: ${{ steps.meta.outputs.tags }}-builder
labels: ${{ steps.meta.outputs.labels }}-builder
54 changes: 54 additions & 0 deletions Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FROM alpine:edge

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

ENV PYTHONUNBUFFERED=1
ENV PIPENV_VERBOSITY=-1
ENV VIRTUAL_ENV=/opt/env
ENV UV_PROJECT_ENVIRONMENT=/opt/env
ENV WORKING_DIR=/opt/invenio
ENV INVENIO_INSTANCE_PATH=${WORKING_DIR}/var/instance
ENV PYTHONUSERBASE=$VIRTUAL_ENV
ENV PATH=$VIRTUAL_ENV/bin:$PATH
ENV PYTHONPATH $VIRTUAL_ENV/lib/python3.12:$PATH

RUN apk update
RUN apk add --update --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community \
"python3>3.12" \
"python3-dev>3.12" \
"nodejs>20" \
"npm>10" \
git \
cairo \
autoconf \
automake \
bash \
build-base \
file \
gcc \
libtool \
libxml2-dev \
libxslt-dev \
linux-headers \
xmlsec-dev \
xmlsec \
uv

RUN uv venv ${VIRTUAL_ENV}
RUN source ${VIRTUAL_ENV}/bin/activate

# necessary because of https://github.com/xmlsec/python-xmlsec/pull/325
ENV CFLAGS="-Wno-error=incompatible-pointer-types"

# not more necessary after new release of xmlsec
# https://github.com/xmlsec/python-xmlsec/issues/316
# --only-binary is not working!!!! it builds but it fails on runtime
RUN uv pip install --no-binary=xmlsec --no-binary=lxml lxml xmlsec

WORKDIR ${WORKING_DIR}/src

RUN mkdir -p ${INVENIO_INSTANCE_PATH}

ENTRYPOINT [ "bash", "-c"]
39 changes: 39 additions & 0 deletions Dockerfile.frontend
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM alpine:edge

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

ENV VIRTUAL_ENV=/opt/env
ENV UV_PROJECT_ENVIRONMENT=/opt/env
ENV WORKING_DIR=/opt/invenio
ENV INVENIO_INSTANCE_PATH=${WORKING_DIR}/var/instance
ENV PATH=$VIRTUAL_ENV/bin:$PATH

RUN apk update

# ttf-dejavu: for doi badges
RUN apk add --update --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community \
"python3>3.12" \
libxslt-dev \
xmlsec \
cairo \
uwsgi-python3 \
fontconfig \
ttf-dejavu \
bash \
uv

RUN uv venv ${VIRTUAL_ENV}
RUN source ${VIRTUAL_ENV}/bin/activate

RUN mkdir -p ${INVENIO_INSTANCE_PATH}
RUN mkdir -p ${VIRTUAL_ENV}
RUN mkdir -p ${WORKING_DIR}/src/saml/idp/cert

RUN adduser invenio --no-create-home --disabled-password

RUN rm /opt/env/bin/python && ln -s /usr/bin/python python

ENTRYPOINT [ "bash", "-c"]

11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# docker-invenio-base

invenioRDM base images

This images serves as base image, usable in production environments like Kubernetes or OpenShift, for: [InvenioRDM](https://github.com/inveniosoftware/invenio-app-rdm)


The *current images* is based on the **alpine** version edge and contains:

- Python v3.12 set as default Python interpreter with upgraded versions of pip, uv.
- Node.js > v20.x
- NPM > v10
- Working directory for an Invenio instance.

0 comments on commit 0a86782

Please sign in to comment.