Skip to content

Commit

Permalink
initial working commit
Browse files Browse the repository at this point in the history
  • Loading branch information
feederbox826 committed Nov 21, 2023
0 parents commit d12777d
Show file tree
Hide file tree
Showing 43 changed files with 419 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/docker-cuda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: docker-cuda-build
on:
push:
paths:
- cuda.Dockerfile
- stash-cuda/**
- stash/**
workflow_dispatch:
schedule:
- cron: '0 0 1 * *'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
push: true
file: cuda.Dockerfile
tags: ghcr.io/${{ github.repository_owner }}/stash-s6:cuda
25 changes: 25 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: docker-build
on:
push:
paths:
- alpine.Dockerfile
- stash/**
workflow_dispatch:
schedule:
- cron: '0 0 1 * *'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
push: true
file: alpine.Dockerfile
tags: ghcr.io/${{ github.repository_owner }}/stash-s6:alpine
Empty file added README.md
Empty file.
69 changes: 69 additions & 0 deletions alpine.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# syntax=docker/dockerfile:1

FROM alpine:edge as s6-builder
# https://github.com/just-containers/s6-overlay/releases
ARG S6_OVERLAY_VERSION="3.1.6.2"
ARG S6_OVERLAY_ARCH="x86_64"
WORKDIR /root-out

# add s6 overlay
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
RUN tar -C /root-out -Jxpf /tmp/s6-overlay-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz /tmp
RUN tar -C /root-out -Jxpf /tmp/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz

# add s6 optional symlinks
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz /tmp
RUN tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz /tmp
RUN tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz

FROM alpine:3.18
# add stash
COPY --from=s6-builder /root-out/ /
# ubuntu environment variables
ENV HOME="/root" \
TZ="Etc/UTC" \
LANG="en_US.UTF-8" \
LANGUAGE="en_US:en" \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME="0" \
# stash environment variables
STASH_PORT="9999" \
STASH_GENERATED="/data/generated" \
STASH_CACHE="/data/cache" \
STASH_METADATA="/config/metadata" \
STASH_CONFIG_FILE="/config/config.yaml" \
# python env
PIP_INSTALL_TARGET="/pip-install"

RUN \
echo "**** install packages ****" && \
apk add --no-cache \
bash \
ca-certificates \
curl \
ffmpeg \
python3 \
py3-pip \
shadow \
tzdata \
vips-tools \
wget && \
echo "**** create stash user and make our folders ****" && \
useradd -u 1000 -U -d /config -s /bin/false stash && \
usermod -G users stash && \
mkdir -p \
/app \
/config \
/config/.stash \
/data \
/defaults && \
echo "**** cleanup ****"

COPY stash/root/ /
COPY --from=stashapp/stash /usr/bin/stash /app/stash

VOLUME /pip-install

EXPOSE 9999
ENTRYPOINT ["/init"]
90 changes: 90 additions & 0 deletions cuda.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# syntax=docker/dockerfile:1

FROM alpine:edge as s6-builder
# https://github.com/just-containers/s6-overlay/releases
ARG S6_OVERLAY_VERSION="3.1.6.2"
ARG S6_OVERLAY_ARCH="x86_64"
WORKDIR /root-out

# add s6 overlay
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
RUN tar -C /root-out -Jxpf /tmp/s6-overlay-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz /tmp
RUN tar -C /root-out -Jxpf /tmp/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz

# add s6 optional symlinks
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz /tmp
RUN tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz /tmp
RUN tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz

# add nvenc patch
ADD --chmod=0755 https://raw.githubusercontent.com/keylase/nvidia-patch/master/patch.sh /root-out/usr/local/bin/

FROM ubuntu:jammy
# add stash
COPY --from=stashapp/stash /usr/bin/stash /app/stash
COPY --from=s6-builder /root-out/ /
ARG DEBIAN_FRONTEND="noninteractive"
# ubuntu environment variables
ENV HOME="/root" \
TZ="Etc/UTC" \
LANG="en_US.UTF-8" \
LANGUAGE="en_US:en" \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME="0" \
# stash environment variables
STASH_PORT="9999" \
STASH_GENERATED="/data/generated" \
STASH_CACHE="/data/cache" \
STASH_METADATA="/config/metadata" \
STASH_CONFIG_FILE="/config/config.yaml" \
# python env
PIP_INSTALL_TARGET="/pip-install" \
# hardware env
LIBVA_DRIVERS_PATH="/usr/local/lib/x86_64-linux-gnu/dri" \
NVIDIA_DRIVER_CAPABILITIES="compute,video,utility" \
NVIDIA_VISIBLE_DEVICES="all"

RUN \
echo "**** install apt-utils and locales ****" && \
apt-get update && \
apt-get install -y \
apt-utils \
locales && \
echo "**** install packages ****" && \
apt-get install -y \
--no-install-recommends \
--no-install-suggests \
ca-certificates \
curl \
gnupg \
libvips-tools \
python3 \
python3-pip \
tzdata \
wget && \
echo "**** generate locale ****" && \
locale-gen en_US.UTF-8 && \
echo "**** create stash user and make our folders ****" && \
useradd -u 1000 -U -d /config -s /bin/false stash && \
usermod -G users stash && \
mkdir -p \
/app \
/config \
/config/.stash \
/data \
/defaults && \
echo "**** cleanup ****" && \
apt-get autoremove && \
apt-get clean && \
rm -rf \
/tmp/* \
/var/lib/apt/lists/* \
/var/tmp/* \
/var/log/*

COPY stash/root/ /
COPY stash-cuda/root/ /

EXPOSE 9999
ENTRYPOINT ["/init"]
46 changes: 46 additions & 0 deletions old-dockerfile/cuda.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM stashapp/stash as stash

FROM alpine as build
RUN apk add ca-certificates wget
WORKDIR /tmp
RUN mkdir -p \
/patched-lib && \
wget -O /tmp/patch.sh \
https://raw.githubusercontent.com/keylase/nvidia-patch/master/patch.sh && \
wget -O /tmp/docker-entrypoint.sh \
https://raw.githubusercontent.com/keylase/nvidia-patch/master/docker-entrypoint.sh && \
chmod +x \
/tmp/patch.sh \
/tmp/docker-entrypoint.sh \

# Final Runnable Image
FROM nvidia/cuda:12.0.1-base-ubuntu22.04

COPY --from=stashapp/stash /usr/bin/stash /usr/bin/
RUN apt update && \
apt install -y \
libvips-tools \
ffmpeg \
python3-pip && \
rm -rf /var/lib/apt/lists/*

# NVENC Patch
RUN mkdir -p \
/usr/local/bin \
/patched-lib && \
COPY --from=build /tmp /usr/local/bin/

# pip packages
RUN pip3 install \
requests \
bs4 \
lxml \
pystashlib \
stashapp-tools

ENV LANG C.UTF-8
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES=video,utility
ENV STASH_CONFIG_FILE=/root/.stash/config.yml
EXPOSE 9999
ENTRYPOINT ["docker-entrypoint.sh", "stash"]
23 changes: 23 additions & 0 deletions old-dockerfile/intel.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM stashapp/stash as stash

FROM ghcr.io/linuxserver/ffmpeg:latest

COPY --from=stashapp/stash /usr/bin/stash /usr/bin/
RUN apt update && \
apt install -y \
libvips-tools \
vainfo \
python3-pip && \
rm -rf /var/lib/apt/lists/*

# pip packages
RUN pip3 install \
requests \
bs4 \
lxml \
pystashlib \
stashapp-tools

ENV STASH_CONFIG_FILE=/root/.stash/config.yml
EXPOSE 9999
ENTRYPOINT ["stash"]
15 changes: 15 additions & 0 deletions old-dockerfile/original.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine:latest
COPY --from=stashapp/stash /usr/bin/stash /usr/bin/

RUN apk add --no-cache \
ca-certificates vips-tools ffmpeg python3 py3-pip && \
pip3 install \
requests \
bs4 \
lxml \
pystashlib \
stashapp-tools

ENV STASH_CONFIG_FILE=/root/.stash/config.yml
EXPOSE 9999
ENTRYPOINT ["stash"]
Empty file.
15 changes: 15 additions & 0 deletions stash-cuda/root/etc/s6-overlay/s6-rc.d/init-nvidia-patch/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/command/with-contenv bash
# shellcheck shell=bash

# copied from https://github.com/keylase/nvidia-patch/blob/master/docker-entrypoint.sh
echo "/patched-lib" > /etc/ld.so.conf.d/000-patched-lib.conf && \
mkdir -p "/patched-lib" && \
PATCH_OUTPUT_DIR=/patched-lib /usr/local/bin/patch.sh && \
cd /patched-lib && \
for f in * ; do
suffix="${f##*.so}"
name="$(basename "$f" "$suffix")"
[ -h "$name" ] || ln -sf "$f" "$name"
[ -h "$name" ] || ln -sf "$f" "$name.1"
done && \
ldconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-nvidia/patch/run
Empty file.
5 changes: 5 additions & 0 deletions stash/root/defaults/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bs4
lxml
pystashlib
requests
stashapp-tools
Empty file.
10 changes: 10 additions & 0 deletions stash/root/etc/s6-overlay/s6-rc.d/init-ffmpeg/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/command/with-contenv bash
# shellcheck shell=bash

# link download libraries
if [[ ! -e "$/config/.stash/ffmpeg" ]]; then
ln -s "/usr/local/bin" "/config/.stash/ffmpeg"
fi
if [[ ! -e "/config/.stash/ffprobe" ]]; then
ln -s "/usr/local/bin/ffprobe" "/config/.stash/ffprobe"
fi
1 change: 1 addition & 0 deletions stash/root/etc/s6-overlay/s6-rc.d/init-ffmpeg/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions stash/root/etc/s6-overlay/s6-rc.d/init-ffmpeg/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-ffmpeg/run
Empty file.
6 changes: 6 additions & 0 deletions stash/root/etc/s6-overlay/s6-rc.d/init-migrate/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/command/with-contenv bash
# shellcheck shell=bash

# hotio migration

# stashapp/stash migration
1 change: 1 addition & 0 deletions stash/root/etc/s6-overlay/s6-rc.d/init-migrate/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions stash/root/etc/s6-overlay/s6-rc.d/init-migrate/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-migrate/run
Empty file.
1 change: 1 addition & 0 deletions stash/root/etc/s6-overlay/s6-rc.d/init-perms/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions stash/root/etc/s6-overlay/s6-rc.d/init-perms/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
find /etc/s6-overlay/s6-rc.d -name "run*" -exec chmod +x {} +
Empty file.
12 changes: 12 additions & 0 deletions stash/root/etc/s6-overlay/s6-rc.d/init-python-reqs/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

## check for existing requirements.txt
if [[ ! -f /config/requirements.txt ]]; then
cp /defaults/requirements.txt /config/requirements.txt
fi

## install and upgrade python requirements
echo "Installing/upgrading python requirements..."
pip3 install --upgrade --target "$PIP_INSTALL_TARGET" -r /config/requirements.txt
export PYTHONPATH="$PYTHONPATH:$PIP_INSTALL_TARGET"
1 change: 1 addition & 0 deletions stash/root/etc/s6-overlay/s6-rc.d/init-python-reqs/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions stash/root/etc/s6-overlay/s6-rc.d/init-python-reqs/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-python-reqs/run
Loading

0 comments on commit d12777d

Please sign in to comment.