This repository has been archived by the owner on Jan 23, 2024. It is now read-only.
forked from kozec/sc-controller
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Dockerfile
44 lines (35 loc) · 1.75 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
ARG BASE_OS=ubuntu
ARG BASE_CODENAME=jammy
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
# 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
# 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)"
# 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
# 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}"
# 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
# Store build metadata
ARG TARGETOS TARGETARCH TARGETVARIANT
RUN export "TARGETMACHINE=$(uname -m)" && printenv | grep ^TARGET >>/build/.build-metadata.env
# Keep only files required for runtime
FROM scratch AS export-stage
COPY --from=build-stage /build /