Skip to content

Commit

Permalink
Merge pull request #23 from GhostofGoes/fix-ci-improve-docker
Browse files Browse the repository at this point in the history
Fix CI and improve Docker build
  • Loading branch information
GhostofGoes committed May 6, 2024
2 parents e4cfe0e + 5efa97f commit 0d13eaf
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 28 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ on:
branches: [ "main", "**" ]

jobs:

build:

name: Build Docker image
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag sceptre-bennu:$(date +%s)
- name: Check out the repo
uses: actions/checkout@v4
- name: Build the Docker image
run: docker build --pull --file Dockerfile --tag sceptre-bennu:$(date +%s) .
11 changes: 5 additions & 6 deletions .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,35 @@ env:
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
name: Build and push Docker image
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
#
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

44 changes: 28 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
ARG REGISTRY_IMAGE="ubuntu:20.04"
ARG PIP_INDEX="https://pypi.org/"
ARG PIP_INDEX_URL="https://pypi.org/simple"

# create python build image
FROM ubuntu:20.04 AS pybuilder
FROM ${REGISTRY_IMAGE} AS pybuilder

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND="noninteractive" \
PIP_DISABLE_PIP_VERSION_CHECK=1

RUN apt update \
&& apt install -y \
RUN apt-get update \
&& apt-get install -y \
build-essential cmake git wget python3-dev python3-pip \
libfreetype6-dev liblapack-dev libboost-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# setup ZMQ
Expand All @@ -26,36 +32,37 @@ RUN wget -O helics.tgz https://github.com/GMLC-TDC/HELICS/releases/download/v${H
&& tar -C /tmp/helics -xzf helics.tgz \
&& rm helics.tgz \
&& mkdir -p /tmp/helics/build && cd /tmp/helics/build \
&& cmake -D HELICS_USE_SYSTEM_ZEROMQ_ONLY=ON .. \
&& cmake -j$(nproc) -D HELICS_USE_SYSTEM_ZEROMQ_ONLY=ON .. \
&& make -j$(nproc) install

RUN python3 -m pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pyzmq~=20.0.0 --install-option=--enable-drafts
RUN python3 -m pip install --no-cache-dir pyzmq~=20.0.0 --install-option=--enable-drafts

RUN wget -O pyhelics.tgz https://github.com/GMLC-TDC/pyhelics/releases/download/v${HELICS_VERSION}/helics-${HELICS_VERSION}.tar.gz \
&& mkdir -p /tmp/pyhelics \
&& tar -C /tmp/pyhelics -xzf pyhelics.tgz \
&& rm pyhelics.tgz \
&& cd /tmp/pyhelics/helics-${HELICS_VERSION} \
&& sed -i 's/helics-apps/helics-apps~=2.7.1/' setup.py \
&& python3 -m pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org .
&& python3 -m pip install --no-cache-dir .

#DEBUG build
#ADD docker/vendor /tmp/bennu/vendor
#WORKDIR /tmp/bennu/vendor/helics-helper
#RUN python3 -m pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org .
#RUN python3 -m pip install .

# install Python bennu package
ADD src/pybennu /tmp/bennu/src/pybennu
WORKDIR /tmp/bennu/src/pybennu
RUN python3 -m pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org .
RUN python3 -m pip install --no-cache-dir .

# create final image
FROM ubuntu:20.04
FROM ${REGISTRY_IMAGE}

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND="noninteractive" \
PIP_DISABLE_PIP_VERSION_CHECK=1

RUN apt update \
&& apt install -y \
RUN apt-get update \
&& apt-get install -y \
# bennu
build-essential ca-certificates cmake cmake-curses-gui \
git wget pkg-config libasio-dev libsodium-dev \
Expand All @@ -68,6 +75,7 @@ RUN apt update \
libffi-dev ruby-dev ruby-ffi \
# python
python3-dev python3-pip python3-setuptools python3-wheel \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# setup Go
Expand Down Expand Up @@ -97,11 +105,15 @@ ADD test /tmp/bennu/test

# install C++ and Golang bennu package
WORKDIR /tmp/bennu/build
RUN cmake -D BUILD_GOBENNU=OFF ../ && make -j$(nproc) install \
RUN cmake -j$(nproc) -D BUILD_GOBENNU=OFF ../ \
&& make -j$(nproc) install \
&& rm -rf /tmp/*

RUN gem install fpm
RUN pip3 install --trusted-host pypy.org --trusted-host files.pythonhosted.org -U aptly-ctl pip setuptools twine wheel
# Gem install failures: https://github.com/jordansissel/fpm/issues/2048
# For now, manually install dotenv 2.8.1
RUN gem install dotenv -v 2.8.1 && gem install fpm -v 1.15.1

RUN python3 -m pip install --no-cache-dir --upgrade aptly-ctl pip setuptools twine wheel

WORKDIR /root
CMD /bin/bash

0 comments on commit 0d13eaf

Please sign in to comment.