-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathDockerfile
More file actions
127 lines (107 loc) · 3.44 KB
/
Copy pathDockerfile
File metadata and controls
127 lines (107 loc) · 3.44 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# syntax=docker/dockerfile:1
# artifacts: false
# platforms: linux/amd64
# Linuxserver.io docker mods are not multiplatform, so no point in enabling "linux/arm64/v8"
# cannot enable "linux/arm/v7" due to issue with dotnet
FROM ubuntu:26.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
ENV VIRTUAL_ENV=/opt/venv
ENV UV_PROJECT_ENVIRONMENT=${VIRTUAL_ENV}
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
set -e
apt-get update -y
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
libbrotli1 \
libc6 \
libgcc-s1 \
libgssapi-krb5-2 \
libicu78 \
libssl3t64 \
libstdc++6 \
python3 \
python3-venv \
tzdata \
unzip \
zlib1g
apt-get clean
rm -rf /var/lib/apt/lists/*
_DEPS
# install dotnet-sdk
WORKDIR /tmp
RUN <<_DOTNET
#!/bin/bash
set -e
url="https://dot.net/v1/dotnet-install.sh"
curl --proto "=https" --tlsv1.2 --silent --show-error --fail --location "$url" --output dotnet-install.sh
chmod +x ./dotnet-install.sh
./dotnet-install.sh --channel 9.0
_DOTNET
# install uv
RUN <<_UV
#!/bin/bash
set -e
url="https://astral.sh/uv/install.sh"
curl --proto "=https" --tlsv1.2 --silent --show-error --fail --location "$url" --output uv-install.sh
sh uv-install.sh
_UV
# add dotnet, uv, and the project environment to path
ENV PATH="/root/.dotnet:/root/.local/bin:${VIRTUAL_ENV}/bin:${PATH}"
# create build dir and copy the files required to restore dependencies and build the plugin
WORKDIR /build
COPY --link pyproject.toml uv.lock README.md LICENSE Directory.Build.props Jellyfin.Plugin.Themerr.sln ./
COPY --link themerr-jellyfin.png ./
COPY --link scripts/ scripts/
COPY --link Jellyfin.Plugin.Themerr/ Jellyfin.Plugin.Themerr/
COPY --link Jellyfin.Plugin.Themerr.Tests/ Jellyfin.Plugin.Themerr.Tests/
COPY --link Locale/ Locale/
COPY --link dockermod_root/ dockermod_root/
# install Python dependencies
RUN <<_UV_SYNC
#!/bin/bash
set -e
uv sync --frozen --only-group dev --python python3 --no-python-downloads --no-build --no-install-project
_UV_SYNC
# build
RUN <<_BUILD
#!/bin/bash
# force the workflow to fail if any command fails
set -e
# build wrapper generates build.yaml and creates the output directory for jprm
uv run --frozen \
--no-sync python \
./scripts/build_plugin.py \
--version="${BUILD_VERSION}" \
--output="./artifacts" \
--verbosity=debug
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/ /
# The docker mod is consumed as a filesystem layer, not run as a standalone root container.
USER 65532:65532