forked from LizardByte/Themerr-jellyfin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
108 lines (90 loc) · 2.67 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# syntax=docker/dockerfile:1.4
# artifacts: false
# platforms: linux/amd64,linux/arm64/v8
# cannot enable "linux/arm/v7" due to issue with dotnet
FROM ubuntu:22.04 AS base
ENV DEBIAN_FRONTEND=noninteractive
FROM base as buildstage
# build args
ARG BUILD_VERSION
ARG COMMIT
ARG GITHUB_SHA=$COMMIT
# note: BUILD_VERSION may be blank, COMMIT is also available
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# install dependencies
# dotnet deps: https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#dependencies
RUN <<_DEPS
#!/bin/bash
apt-get update -y
apt-get install -y --no-install-recommends \
libc6 \
libgcc-s1 \
libgssapi-krb5-2 \
libicu70 \
liblttng-ust1 \
libssl3 \
libstdc++6 \
libunwind8 \
python3 \
python3-pip \
unzip \
wget \
zlib1g
apt-get clean
rm -rf /var/lib/apt/lists/*
_DEPS
# install dotnet-sdk
WORKDIR /tmp
RUN <<_DOTNET
#!/bin/bash
url="https://dot.net/v1/dotnet-install.sh"
wget --quiet "$url" -O dotnet-install.sh
chmod +x ./dotnet-install.sh
./dotnet-install.sh --channel 6.0
_DOTNET
# add dotnet to path
ENV PATH="${PATH}:/root/.dotnet"
# create build dir and copy GitHub repo there
COPY --link . /build
# set build dir
WORKDIR /build
# update pip
RUN <<_PIP
#!/bin/bash
python3 -m pip install --no-cache-dir --upgrade \
pip setuptools wheel
python3 -m pip install --no-cache-dir -r requirements-dev.txt
_PIP
# build
RUN <<_BUILD
#!/bin/bash
# force the workflow to fail if any command fails
set -e
# jprm fails if output directory does not exist, so create it
mkdir -p ./artifacts
# check if build version is empty or "v" (v may be supplied with no version for PR events)
if [[ -z "${BUILD_VERSION}" || "${BUILD_VERSION}" == "v" ]]; then
BUILD_VERSION="0.0.0.0"
else
# remove the v prefix from the version
BUILD_VERSION="${BUILD_VERSION#v}"
fi
python3 -m jprm --verbosity=debug plugin build "./" --version="${BUILD_VERSION}" --output="./artifacts"
mkdir -p /artifacts
unzip ./artifacts/*.zip -d /artifacts
_BUILD
# apply permissions to s6 run script
RUN chmod +x ./dockermod_root/etc/s6-overlay/s6-rc.d/init-mod-jellyfin-themerr-config/run
FROM scratch AS layer_stage
# variables
ARG PLUGIN_NAME="themerr-jellyfin"
ARG PLUGIN_DIR="/root-layer/config/data/plugins"
# add files from buildstage
# trailing slash on artifacts directory copies the contents of the directory, instead of the directory itself
COPY --link --from=buildstage /artifacts/ $PLUGIN_DIR/$PLUGIN_NAME
# copy s6 initialization files
COPY --link --from=buildstage /build/dockermod_root/ /root-layer
FROM scratch AS deploy
# Linuxserver.io docker mods require that mods be fully contained in a single layer
# copy s6 initialization files
COPY --link --from=layer_stage /root-layer/ /