Skip to content

Commit

Permalink
Dockerfile: Migrate to Noble and make it more readable with heredocs,…
Browse files Browse the repository at this point in the history
… using way less layers and cleaning up apt
  • Loading branch information
C0rn3j committed Aug 21, 2024
1 parent 2ec0571 commit 4029a20
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,49 @@
ARG BASE_OS=ubuntu
ARG BASE_CODENAME=jammy
ARG BASE_CODENAME=noble
FROM $BASE_OS:$BASE_CODENAME AS build-stage

# Download build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc librsvg2-bin linux-headers-generic python3-dev python3-setuptools

RUN <<EOR
apt-get update
apt-get install -y --no-install-recommends \
gcc \
librsvg2-bin \
linux-headers-generic \
python3-dev \
python3-setuptools \
python-is-python3
apt-get clean && rm -rf /var/lib/apt/lists/*
EOR
# Prepare working directory and target
COPY . /work
WORKDIR /work
ARG TARGET=/build/usr

# Build and install
RUN python3 setup.py build --executable "/usr/bin/env python3" && \
python3 setup.py install --single-version-externally-managed --home "${TARGET}" --record /dev/null
RUN <<EOR
python setup.py build --executable "/usr/bin/env python3"
python setup.py install --single-version-externally-managed --home "${TARGET}" --record /dev/null

# Provide input-event-codes.h as fallback for runtime systems without linux headers
RUN cp -a \
"$(find /usr -type f -name input-event-codes.h -print -quit)" \
"$(find "${TARGET}" -type f -name uinput.py -printf '%h\n' -quit)"
cp -a \
"$(find /usr -type f -name input-event-codes.h -print -quit)" \
"$(find "${TARGET}" -type f -name uinput.py -printf '%h\n' -quit)"

# Create short name symlinks for static libraries
RUN suffix=".cpython-*-$(uname -m)-linux-gnu.so" && \
find "${TARGET}" -type f -path "*/site-packages/*${suffix}" \
| while read -r path; do ln -sfr "${path}" "${path%${suffix}}.so"; done
suffix=".cpython-*-$(uname -m)-linux-gnu.so"
find "${TARGET}" -type f -path "*/site-packages/*${suffix}" \
| while read -r path; do ln -sfr "${path}" "${path%${suffix}}.so"; done

# Put AppStream metadata to required location according to https://wiki.debian.org/AppStream/Guidelines
RUN metainfo=/build/usr/share/metainfo && \
mkdir -p "${metainfo}" && \
cp -a scripts/sc-controller.appdata.xml "${metainfo}"
metainfo=/build/usr/share/metainfo
mkdir -p "${metainfo}"
cp -a scripts/sc-controller.appdata.xml "${metainfo}"

# Convert icon to png format (required for icons in .desktop file)
RUN iconpath="${TARGET}/share/icons/hicolor/512x512/apps" && \
mkdir -p "${iconpath}" && \
rsvg-convert --background-color none -o "${iconpath}/sc-controller.png" images/sc-controller.svg
iconpath="${TARGET}/share/icons/hicolor/512x512/apps"
mkdir -p "${iconpath}"
rsvg-convert --background-color none -o "${iconpath}/sc-controller.png" images/sc-controller.svg
EOR

# Store build metadata
ARG TARGETOS TARGETARCH TARGETVARIANT
Expand Down

0 comments on commit 4029a20

Please sign in to comment.