Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Remove self-hosted, remove alpine
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbosch committed Dec 14, 2023
1 parent c333f62 commit e925d3b
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 51 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/kuksa_csv_provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
build-csv-provider-image:
name: "Build csv provider image"
runs-on: self-hosted
runs-on: ubuntu-latest
needs: check_ghcr_push

steps:
Expand All @@ -75,11 +75,11 @@ jobs:
type=semver,pattern={{major}}
# only needed for runners without buildx setup, will be slow
#- name: Set up QEMU
# uses: docker/setup-qemu-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

#- name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container registry
if: needs.check_ghcr_push.outputs.push == 'true'
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/kuksa_dbc_feeder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,11 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
# only needed for runners without buildx setup, will be slow
#- name: Set up QEMU
# uses: docker/setup-qemu-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

#- name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container registry
if: needs.check_ghcr_push.outputs.push == 'true'
Expand Down
24 changes: 16 additions & 8 deletions .github/workflows/kuksa_gps_feeder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ jobs:
uses: eclipse-kuksa/kuksa-actions/.github/workflows/check_ghcr_push.yml@2
secrets: inherit

build-self-hosted:
# TODO - Integrate push right check similar to other repos

build-ubuntu-latest:
if: ${{ github.repository_owner == 'eclipse' }}
runs-on: [ self-hosted ]
runs-on: [ ubuntu-latest ]
needs: check_ghcr_push

# With default permissions, release action fails on forks
Expand All @@ -36,6 +38,12 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
Expand Down Expand Up @@ -88,6 +96,7 @@ jobs:
with:
platforms: |
linux/amd64
linux/arm64
context: gps2val
push: true
tags: ${{ env.EPHEMERAL_IMAGE }}
Expand Down Expand Up @@ -116,10 +125,8 @@ jobs:
steps:
- uses: actions/checkout@v3

## NOTE: Uncomment following step if you want to build arm64 image without self-hosted runner on eclipse. It needs ~3h to finish!

# - name: Set up QEMU
# uses: docker/setup-qemu-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand Down Expand Up @@ -153,6 +160,7 @@ jobs:
with:
platforms: |
linux/amd64
linux/arm64
context: gps2val
push: true
tags: |
Expand All @@ -165,7 +173,7 @@ jobs:
with:
image: ${{ steps.meta.outputs.tags }}
docker-run-args: "-it --rm"
message: "**NOTE:** Only **linux/amd64** image is included (self-hosted runner not available on forks)"
message: "**NOTE:** Only **linux/amd64** image is included "


- name: Build ephemeral KUKSA gps feeder and push to ttl.sh
Expand All @@ -185,4 +193,4 @@ jobs:
with:
image: ${{ env.EPHEMERAL_IMAGE }}
docker-run-args: "-it --rm"
message: "**NOTE:** Only **linux/amd64** image is included (self-hosted runner not available on forks)"
message: "**NOTE:** Only **linux/amd64** image is included"
30 changes: 20 additions & 10 deletions csv_provider/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,30 @@


# Build stage, to create a Virtual Environent
FROM --platform=$TARGETPLATFORM python:3.10-alpine as builder
FROM --platform=$TARGETPLATFORM python:3.10-slim-bookworm as builder

ARG TARGETPLATFORM
ARG BUILDPLATFORM

RUN echo "-- Running on $BUILDPLATFORM, building for $TARGETPLATFORM"

RUN apk update && apk add alpine-sdk linux-headers
RUN apt update && apt -yy install binutils git

COPY . /
# It seems 3.10-slim-bookworm shall have gcc, but for aarch64 where it is needed
# it does not seem to be present, needed to build bitstruct
# https://github.com/docker-library/python/blob/master/3.10/slim-bookworm/Dockerfile
# RUN apt -yy install gcc

RUN python3 -m venv /opt/venv
RUN pip install --upgrade --no-cache-dir pip build pyinstaller

ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt /

RUN /opt/venv/bin/python3 -m pip install --upgrade pip \
&& pip3 install --no-cache-dir -r requirements.txt
RUN pip3 install --no-cache-dir -r requirements.txt

# Copy "all" files first when dependencies have been installed to reuse
# cached layers as much as possible

RUN pip3 install wheel scons && pip3 install pyinstaller
COPY . /

RUN pyinstaller --clean -F -s provider.py

Expand All @@ -42,14 +46,20 @@ WORKDIR /data
COPY ./signals.csv ./signals.csv

# Runner stage, to copy in the virtual environment and the app
FROM alpine:3

# Debian 12 is bookworm, so the glibc version matches. Distroless is a lot smaller than
# Debian slim versions
# For development add :debug like this
# FROM gcr.io/distroless/base-debian12:debug to get a busybox shell as well
FROM gcr.io/distroless/base-debian12

WORKDIR /dist

COPY --from=builder /dist/* .
COPY --from=builder /data/ ./

# pyinstaller doesn't pick up transient libz dependency, so copying it manually
COPY --from=builder /usr/lib/*-linux-gnu/libz.so.1 /lib/

ENV PATH="/dist:$PATH"

# useful dumps about feeding values
Expand Down
40 changes: 25 additions & 15 deletions dbc2val/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,35 @@


# Build stage, to create a Virtual Environent
FROM --platform=$TARGETPLATFORM python:3.10-alpine as builder
FROM --platform=$TARGETPLATFORM python:3.10-slim-bookworm as builder

ARG TARGETPLATFORM
ARG BUILDPLATFORM

RUN echo "-- Running on $BUILDPLATFORM, building for $TARGETPLATFORM"

# cmake and opanblas-dev needed for aarch build
RUN apk update && apk add alpine-sdk linux-headers cmake openblas-dev
# It seems 3.10-slim-bookworm shall have gcc, but for aarch64 where it is needed
# it does not seem to be present, needed to build bitstruct
# https://github.com/docker-library/python/blob/master/3.10/slim-bookworm/Dockerfile
RUN apt update && apt -y install \
binutils \
git \
gcc \
&& rm -rf /var/lib/apt/lists/*

COPY . /

RUN python3 -m venv /opt/venv
RUN pip install --upgrade --no-cache-dir pip build pyinstaller

ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt /

RUN /opt/venv/bin/python3 -m pip install --upgrade pip \
&& pip3 install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Copy "all" files first when dependencies have been installed to reuse
# cached layers as much as possible

RUN pip3 install wheel scons && pip3 install pyinstaller
COPY . /

# By default we use certificates and tokens from kuksa_certificates, so they must be included
RUN pyinstaller --collect-data kuksa_certificates --hidden-import can.interfaces.socketcan --clean -F -s dbcfeeder.py
# By default we use certificates and tokens from kuksa_client, so they must be included
RUN pyinstaller --collect-data kuksa_client --hidden-import can.interfaces.socketcan --clean -F -s dbcfeeder.py
# --debug=imports

WORKDIR /dist
Expand All @@ -46,15 +51,20 @@ COPY ./config/* ./config/
COPY ./mapping/ ./mapping/
COPY ./*.dbc ./candump*.log ./*.json ./

# Runner stage, to copy in the virtual environment and the app
FROM alpine:3

# Debian 12 is bookworm, so the glibc version matches. Distroless is a lot smaller than
# Debian slim versions
# For development add :debug like this
# FROM gcr.io/distroless/base-debian12:debug to get a busybox shell as well
FROM gcr.io/distroless/base-debian12

WORKDIR /dist

COPY --from=builder /dist/* .
COPY --from=builder /data/ ./

# pyinstaller doesn't pick up transient libz dependency, so copying it manually
COPY --from=builder /usr/lib/*-linux-gnu/libz.so.1 /lib/

ENV PATH="/dist:$PATH"

# useful dumps about feeding values
Expand Down
20 changes: 12 additions & 8 deletions gps2val/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,26 @@
# * SPDX-License-Identifier: Apache-2.0
# ********************************************************************************/

FROM python:3.10-alpine as build
FROM --platform=$TARGETPLATFORM python:3.10-slim-bookworm as builder

# alpine-sdk and linux-headers needed for Alpine to build grpcio for aarch64, not needed for platforms with prebuilt grpcio
RUN apk add --no-cache alpine-sdk linux-headers
ADD . /kuksa_gps_feeder
WORKDIR /kuksa_gps_feeder
RUN pip install --upgrade pip
# Note - Installing grpcio (inherited from kuksa-viss-client) takes very long time (40-60 minutes) on Alpine
# Note - if relying on kuksa-client pre-releases you must add --pre to the line below
RUN pip install --target /kuksa_gps_feeder --no-cache-dir -r requirements.txt


FROM python:3.10-alpine
# Debian 12 is bookworm, so the glibc version matches. Distroless is a lot smaller than
# Debian slim versions
# For development add :debug like this
# FROM gcr.io/distroless/base-debian12:debug to get a busybox shell as well
FROM --platform=$TARGETPLATFORM python:3.10-slim-bookworm

RUN apk add --no-cache gpsd libstdc++
COPY --from=build /kuksa_gps_feeder /kuksa_gps_feeder
RUN apt update && apt install -y gpsd \
&& rm -rf /var/lib/apt/lists/*

# RUN apk add -yy --no-cache gpsd
COPY --from=builder /kuksa_gps_feeder /kuksa_gps_feeder
COPY --from=builder /bin/sh /bin/sh
WORKDIR /kuksa_gps_feeder

ENV PYTHONUNBUFFERED=yes
Expand Down

0 comments on commit e925d3b

Please sign in to comment.