Skip to content

Commit

Permalink
Add deprecated images to build process
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Heinrich <andreas.heinrich@rwth-aachen.de>
  • Loading branch information
andistorm committed Jul 8, 2024
1 parent 7defa92 commit aee584b
Show file tree
Hide file tree
Showing 9 changed files with 785 additions and 20 deletions.
84 changes: 74 additions & 10 deletions .github/workflows/deploy-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
description: 'Force rebuild of all images'
default: false
type: boolean
build_deprecated_images:
description: 'Build deprecated images'
default: false
type: boolean
push:
branches:
- '**'
Expand All @@ -31,13 +35,19 @@ jobs:
docker_registry: ${{ steps.check.outputs.docker_registry }}
docker_directory: ${{ steps.check.outputs.docker_directory }}
platforms: ${{ steps.check.outputs.platforms }}
repository_name: ${{ steps.check.outputs.repository_name }}
build_deprecated_images: ${{ github.event.inputs.build_deprecated_images }}
steps:
- id: check
run: |
echo "force_rebuild=${{ inputs.force_rebuild || (github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/' )) || false }}" >> $GITHUB_OUTPUT
echo "docker_registry=${{ env.REGISTRY }}" >> $GITHUB_OUTPUT
echo "docker_directory=${{ env.DOCKER_DIRECTORY }}" >> $GITHUB_OUTPUT
echo "platforms=${{ env.PLATFORMS }}" >> $GITHUB_OUTPUT
echo "repository_name=${{ github.event.repository.name }}" >> $GITHUB_OUTPUT
# Build deprecated images if not explicitly disabled
#TODO: set default to false, once backwards compatibility is no longer needed
echo "build_deprecated_images=${{ inputs.build_deprecated_images || true }}" >> $GITHUB_OUTPUT
# One job for each image, since the images build on top of each other a matrix strategy is not possible
everest-clang-format:
Expand All @@ -50,8 +60,8 @@ jobs:
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }}
with:
force_rebuild: ${{ needs.env-setup.outputs.force_rebuild == 'true' }}
image_name: everest-clang-format
docker_directory: ${{ needs.env-setup.outputs.docker_directory }}
image_name: ${{ needs.env-setup.outputs.repository_name }}/everest-clang-format
directory: ${{ needs.env-setup.outputs.docker_directory }}/everest-clang-format
docker_registry: ${{ needs.env-setup.outputs.docker_registry }}
github_ref_before: ${{ github.event.before }}
github_ref_after: ${{ github.event.after }}
Expand All @@ -66,8 +76,8 @@ jobs:
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }}
with:
force_rebuild: ${{ needs.env-setup.outputs.force_rebuild == 'true' }}
image_name: run-env-base
docker_directory: ${{ needs.env-setup.outputs.docker_directory }}
image_name: ${{ needs.env-setup.outputs.repository_name }}/run-env-base
directory: ${{ needs.env-setup.outputs.docker_directory }}/run-env-base
docker_registry: ${{ needs.env-setup.outputs.docker_registry }}
github_ref_before: ${{ github.event.before }}
github_ref_after: ${{ github.event.after }}
Expand All @@ -83,8 +93,8 @@ jobs:
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }}
with:
force_rebuild: ${{ needs.env-setup.outputs.force_rebuild == 'true' }}
image_name: build-env-base
docker_directory: ${{ needs.env-setup.outputs.docker_directory }}
image_name: ${{ needs.env-setup.outputs.repository_name }}/build-env-base
directory: ${{ needs.env-setup.outputs.docker_directory }}/build-env-base
docker_registry: ${{ needs.env-setup.outputs.docker_registry }}
github_ref_before: ${{ github.event.before }}
github_ref_after: ${{ github.event.after }}
Expand All @@ -100,8 +110,8 @@ jobs:
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }}
with:
force_rebuild: ${{ needs.env-setup.outputs.force_rebuild == 'true' }}
image_name: dev-env-base
docker_directory: ${{ needs.env-setup.outputs.docker_directory }}
image_name: ${{ needs.env-setup.outputs.repository_name }}/dev-env-base
directory: ${{ needs.env-setup.outputs.docker_directory }}/dev-env-base
docker_registry: ${{ needs.env-setup.outputs.docker_registry }}
github_ref_before: ${{ github.event.before }}
github_ref_after: ${{ github.event.after }}
Expand All @@ -117,8 +127,62 @@ jobs:
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }}
with:
force_rebuild: ${{ needs.env-setup.outputs.force_rebuild == 'true' }}
image_name: build-kit
docker_directory: ${{ needs.env-setup.outputs.docker_directory }}
image_name: ${{ needs.env-setup.outputs.repository_name }}/build-kit
directory: ${{ needs.env-setup.outputs.docker_directory }}/build-kit
docker_registry: ${{ needs.env-setup.outputs.docker_registry }}
github_ref_before: ${{ github.event.before }}
github_ref_after: ${{ github.event.after }}
platforms: ${{ needs.env-setup.outputs.platforms }}
# Include deprecated images for backwards compatibility
deprecated-everest-clang-format:
if: ${{ needs.env-setup.outputs.build_deprecated_images == 'true' }}
needs:
- env-setup
name: Build and push deprecated everest-clang-format docker image
uses: ./.github/workflows/deploy-single-docker-image.yml
secrets:
SA_GITHUB_PAT: ${{ secrets.SA_GITHUB_PAT }}
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }}
with:
force_rebuild: ${{ needs.env-setup.outputs.force_rebuild == 'true' }}
image_name: everest-clang-format
directory: docker/deprecated-images/everest-clang-format
docker_registry: ${{ needs.env-setup.outputs.docker_registry }}
github_ref_before: ${{ github.event.before }}
github_ref_after: ${{ github.event.after }}
platforms: ${{ needs.env-setup.outputs.platforms }}
deprecated-build-kit-alpine:
if: ${{ needs.env-setup.outputs.build_deprecated_images == 'true' }}
needs:
- env-setup
name: Build and push deprecated build-kit-alpine docker image
uses: ./.github/workflows/deploy-single-docker-image.yml
secrets:
SA_GITHUB_PAT: ${{ secrets.SA_GITHUB_PAT }}
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }}
with:
force_rebuild: ${{ needs.env-setup.outputs.force_rebuild == 'true' }}
image_name: build-kit-alpine
directory: docker/deprecated-images/build-kit
docker_file_name: alpine.Dockerfile
docker_registry: ${{ needs.env-setup.outputs.docker_registry }}
github_ref_before: ${{ github.event.before }}
github_ref_after: ${{ github.event.after }}
platforms: ${{ needs.env-setup.outputs.platforms }}
deprecated-build-kit-debian:
if: ${{ needs.env-setup.outputs.build_deprecated_images == 'true' }}
needs:
- env-setup
name: Build and push deprecated build-kit-debian docker image
uses: ./.github/workflows/deploy-single-docker-image.yml
secrets:
SA_GITHUB_PAT: ${{ secrets.SA_GITHUB_PAT }}
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }}
with:
force_rebuild: ${{ needs.env-setup.outputs.force_rebuild == 'true' }}
image_name: build-kit-debian
directory: docker/deprecated-images/build-kit
docker_file_name: debian.Dockerfile
docker_registry: ${{ needs.env-setup.outputs.docker_registry }}
github_ref_before: ${{ github.event.before }}
github_ref_after: ${{ github.event.after }}
Expand Down
24 changes: 14 additions & 10 deletions .github/workflows/deploy-single-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ on:
description: 'Name of the image to build and push'
required: true
type: string
docker_directory:
description: 'Directory containing the docker directory'
directory:
description: 'Directory containing the Dockerfile'
required: true
type: string
default: docker/
docker_file_name:
description: 'Name of the Dockerfile'
required: false
default: 'Dockerfile'
type: string
docker_registry:
description: 'Docker registry to push to'
required: true
Expand Down Expand Up @@ -62,7 +66,7 @@ jobs:
- name: Get changed files
id: changed-files
run: |
echo "changed_files=$(git diff --name-only ${{ inputs.github_ref_before }} ${{ inputs.github_ref_after }} | grep "^${{inputs.docker_directory}}/${{inputs.image_name}}" | wc -l)" >> $GITHUB_OUTPUT
echo "changed_files=$(git diff --name-only ${{ inputs.github_ref_before }} ${{ inputs.github_ref_after }} | grep "^${{inputs.directory}}" | wc -l)" >> $GITHUB_OUTPUT
working-directory: source

build-and-push:
Expand All @@ -82,12 +86,12 @@ jobs:
- name: Get context / Path of Dockerfile
id: get-context
run: |
if [ -f source/${{ inputs.docker_directory }}/${{ inputs.image_name }}/Dockerfile ]; then
echo "::set-output name=path::source/${{ inputs.docker_directory }}/${{ inputs.image_name }}/"
elif [ -f source/${{ inputs.docker_directory }}/${{ inputs.image_name }}/.devcontainer/Dockerfile ]; then
echo "::set-output name=path::source/${{ inputs.docker_directory }}/${{ inputs.image_name }}/.devcontainer/"
if [ -f source/${{ inputs.directory }}/${{ inputs.docker_file_name }} ]; then
echo "path=source/${{ inputs.directory }}/" >> $GITHUB_OUTPUT
elif [ -f source/${{ inputs.directory }}/.devcontainer/${{ inputs.docker_file_name }} ]; then
echo "path=source/${{ inputs.directory }}/.devcontainer/" >> $GITHUB_OUTPUT
else
echo "No Dockerfile found for image ${{ inputs.image_name }}!"
echo "No Dockerfile found for image ${{ inputs.image_name }} in dokcer_directory ${{ inputs.directory }} with docker_file_name ${{ inputs.docker_file_name }}!"
exit 1
fi
- name: Parse platforms
Expand All @@ -103,7 +107,7 @@ jobs:
uses: docker/metadata-action@v3
with:
images: |
${{ inputs.docker_registry }}/${{ github.repository }}/${{ inputs.image_name }}
${{ inputs.docker_registry }}/${{ github.repository_owner }}/${{ inputs.image_name }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
Expand Down
1 change: 1 addition & 0 deletions docker/deprecated-images/build-kit/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
doc.rst
104 changes: 104 additions & 0 deletions docker/deprecated-images/build-kit/alpine.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# syntax=docker/dockerfile:1
FROM alpine:3.17

ARG EXT_MOUNT=/ext
ARG EVEREST_CMAKE_PATH=/usr/lib/cmake/everest-cmake

RUN apk update && \
apk add --no-cache \
# basic command line tools
git \
curl \
rsync \
bash \
# build tools
samurai \
make \
cmake \
# compilers
binutils \
gcc \
g++ \
# common dev libraries
musl-dev \
linux-headers \
# compiler tools
clang-extra-tools \
ccache \
# python3 support
py3-pip \
# required for testing
gtest-dev


# additional packages
RUN apk add --no-cache \
# required by timezone handling
tzdata \
# required by some everest libraries
boost-dev \
# required by libocpp
sqlite-dev \
openssl-dev \
# required by everest-framework
nodejs-dev \
nodejs \
npm \
# required by packet sniffer module
libpcap-dev \
libevent-dev \
# required by RiseV2G
maven \
# required by pybind11
python3-dev \
# required for certificate generation
openssl \
# required for user and capability support in everest-framework >= 0.9.0
libcap-dev

# Add edge/testing repository to enable installation of lcov, which is not available in the main repository
RUN echo https://dl-cdn.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories
RUN apk update && apk add --no-cache \
lcov=2.0-r2

RUN python3 -m pip install \
environs>=9.5.0 \
pydantic==1.* \
psutil>=5.9.1 \
cryptography>=3.4.6 \
aiofile>=3.7.4 \
py4j>=0.10.9.5 \
netifaces>=0.11.0 \
python-dateutil>=2.8.2 \
gcovr==5.0 \
build

# install edm
RUN python3 -m pip install git+https://github.com/EVerest/everest-dev-environment@v0.5.5#subdirectory=dependency_manager

# install everest-cmake
RUN git clone https://github.com/EVerest/everest-cmake.git $EVEREST_CMAKE_PATH

RUN ( \
cd $EVEREST_CMAKE_PATH \
git checkout v0.4.0 \
rm -r .git \
)

# FIXME (aw): disable ownership check
RUN git config --global --add safe.directory '*'

ENV WORKSPACE_PATH /workspace
ENV ASSETS_PATH /assets

RUN mkdir $ASSETS_PATH
COPY maven-settings.xml $ASSETS_PATH/

ENV EXT_MOUNT $EXT_MOUNT

COPY ./entrypoint.sh /

WORKDIR $WORKSPACE_PATH

ENTRYPOINT ["/entrypoint.sh"]
CMD ["run-script", "init"]
95 changes: 95 additions & 0 deletions docker/deprecated-images/build-kit/debian.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# syntax=docker/dockerfile:1
FROM debian:11.7-slim

ARG EXT_MOUNT=/ext
ARG EVEREST_CMAKE_PATH=/usr/lib/cmake/everest-cmake

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
# basic command line tools
git \
curl \
rsync \
# build tools
ninja-build \
make \
cmake \
# compilers
binutils \
gcc \
g++ \
# common dev libraries
#linux-headers \
# compiler tools
clang-tidy-13 \
ccache \
# python3 support
python3-pip \
# required for testing
libgtest-dev \
lcov

# additional packages
RUN apt-get install --no-install-recommends -y \
# required by some everest libraries
libboost-all-dev \
# required by libocpp
libsqlite3-dev \
libssl-dev \
# required by everest-framework
nodejs \
libnode-dev \
npm \
# required by packet sniffer module
pkg-config \
libpcap-dev \
# required by RiseV2G
maven \
# required for user and capability support in everest-framework >= 0.9.0
libcap-dev

# clean up apt
RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN python3 -m pip install \
environs>=9.5.0 \
pydantic==1.* \
psutil>=5.9.1 \
cryptography>=3.4.6 \
aiofile>=3.7.4 \
py4j>=0.10.9.5 \
netifaces>=0.11.0 \
python-dateutil>=2.8.2 \
gcovr==5.0 \
build

# install edm
RUN python3 -m pip install git+https://github.com/EVerest/everest-dev-environment@v0.5.5#subdirectory=dependency_manager

# install everest-cmake
RUN git clone https://github.com/EVerest/everest-cmake.git $EVEREST_CMAKE_PATH

RUN ( \
cd $EVEREST_CMAKE_PATH \
git checkout v0.4.0 \
rm -r .git \
)

# FIXME (aw): disable ownership check
RUN git config --global --add safe.directory '*'

ENV WORKSPACE_PATH /workspace
ENV ASSETS_PATH /assets

RUN mkdir $ASSETS_PATH
COPY maven-settings.xml $ASSETS_PATH/

ENV EXT_MOUNT $EXT_MOUNT

COPY ./entrypoint.sh /

WORKDIR $WORKSPACE_PATH

ENTRYPOINT ["/entrypoint.sh"]
CMD ["run-script", "init"]
Loading

0 comments on commit aee584b

Please sign in to comment.