Skip to content

Commit

Permalink
部分代码重构,引入 gosu, 删除配置文件相关环境变量
Browse files Browse the repository at this point in the history
  • Loading branch information
VergilGao committed May 10, 2022
1 parent 9c83081 commit 2679b2a
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 266 deletions.
62 changes: 0 additions & 62 deletions .github/workflows/nightly-build.yml

This file was deleted.

20 changes: 11 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: release

on:
push:
tags:
- "*"
workflow_dispatch:
inputs:
version:
description: 'realease 版本号'
required: true

jobs:
build:
Expand All @@ -14,11 +16,10 @@ jobs:

- name: Set up build args
run: |
echo "MDC_VERSION=$(cat VERSION)" >> $GITHUB_ENV
echo "MAJOR_VERSION=${GITHUB_REF_NAME%%.*}" >> $GITHUB_ENV
echo "MINOR_VERSION=${GITHUB_REF_NAME%.*}" >> $GITHUB_ENV
echo "BUILD_VERSION=${GITHUB_REF_NAME%-*}" >> $GITHUB_ENV
echo "TAG_VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "MAJOR_VERSION=${GITHUB_EVENT_INPUTS_VERSION%%.*}" >> $GITHUB_ENV
echo "MINOR_VERSION=${GITHUB_EVENT_INPUTS_VERSION%.*}" >> $GITHUB_ENV
echo "BUILD_VERSION=${GITHUB_EVENT_INPUTS_VERSION%-*}" >> $GITHUB_ENV
echo "TAG_VERSION=${GITHUB_EVENT_INPUTS_VERSION}" >> $GITHUB_ENV
echo "BUILD_DATE=$(date +"%Y-%m-%d")" >> $GITHUB_ENV
- name: Set up QEMU
Expand Down Expand Up @@ -65,9 +66,10 @@ jobs:
vergilgao/avdc:${{ env.TAG_VERSION }}
vergilgao/avdc:latest
build-args: |
MDC_VERSION=${{ env.MDC_VERSION }}
VERSION=${{ env.BUILD_VERSION }}
BUILD_DATE=${{ env.BUILD_DATE }}
cache-from: type=registry,ref=ghcr.io/vergilgao/mdc:buildcache
cache-to: type=registry,ref=ghcr.io/vergilgao/mdc:buildcache,mode=max

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
10 changes: 1 addition & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
- "*.md"
- ".github/workflows/sync-readme.yml"
- ".github/workflows/release.yml"
- ".github/workflows/nightly-build.yml"
- "LICENSE"
pull_request:
paths-ignore:
Expand All @@ -27,10 +26,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Get mdc version
run: |
echo "MDC_VERSION=$(cat VERSION)" >> $GITHUB_ENV

- name: Create Test User and test files
run: |
Expand All @@ -45,20 +40,17 @@ jobs:
- name: Build the test image
run: |
docker build -t vergilgao/mdc:test \
--build-arg MDC_VERSION=${{ env.MDC_VERSION }} \
--build-arg BUILD_DATE=$(date +"%Y-%m-%d") \
.
- name: Run the Test
if: success()
run: |
docker run \
-e SUCCESS_OUTPUT="test_output" \
-e DEBUG=1 \
-e PUID=1024 \
-e PGID=1024 \
-v ${PWD}/test:/data \
vergilgao/mdc:test
find . -name MIFD-046.mp4
find . -name SVDVD-471.mp4
ls -al test
ls -al test
92 changes: 60 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM python:3.8-alpine3.15 as build-stage

ARG PYINSTALLER_TAG
ENV PYINSTALLER_TAG ${PYINSTALLER_TAG:-"v4.8"}

ARG MDC_VERSION
ARG MDC_REQUIREMENTS_SOURCE_VERSION
ENV MDC_REQUIREMENTS_SOURCE_VERSION=${MDC_REQUIREMENTS_SOURCE_VERSION:-0dff1a72c00ae75cdec7c39ebeee5b49e0a520d5}
ARG PILLOW_SOURCE_VERISON
ENV PILLOW_SOURCE_VERISON=${PILLOW_SOURCE_VERISON:-5d070222d21138d2ead002fd33fdf5adcb708941}

# Official Python base image is needed or some applications will segfault.
# PyInstaller needs zlib-dev, gcc, libc-dev, and musl-dev
Expand All @@ -28,27 +28,56 @@ RUN apk --update --no-cache add \
tcl-dev \
# mdc builder depenencies
libxml2-dev \
libxslt-dev && \
libxslt-dev \
# download utils
wget && \
pip install --upgrade pip

RUN git clone https://github.com/python-pillow/Pillow.git /Pillow
RUN pip install virtualenv && virtualenv /vpy && source /vpy/bin/activate && pip install nose

# Build bootloader for alpine
RUN git clone --depth 1 --single-branch --branch ${PYINSTALLER_TAG} https://github.com/pyinstaller/pyinstaller.git /tmp/pyinstaller \
&& cd /tmp/pyinstaller/bootloader \
&& CFLAGS="-Wno-stringop-overflow -Wno-stringop-truncation" python ./waf configure --no-lsb all \
&& pip install .. \
&& rm -Rf /tmp/pyinstaller
# get pillow
RUN cd /tmp && \
wget -q -nc --show-progress --progress=bar:force:noscroll -O /tmp/pillow-$PILLOW_SOURCE_VERISON.tar.gz https://github.com/python-pillow/Pillow/archive/$PILLOW_SOURCE_VERISON.tar.gz && \
tar zxvf /tmp/pillow-$PILLOW_SOURCE_VERISON.tar.gz && \
rm /tmp/pillow-$PILLOW_SOURCE_VERISON.tar.gz && \
mv Pillow-$PILLOW_SOURCE_VERISON /Pillow && \
pip install virtualenv && \
virtualenv /vpy && \
source /vpy/bin/activate && \
pip install nose

# install requirements
RUN cd /tmp && \
wget -q -nc --show-progress --progress=bar:force:noscroll -O /tmp/mdc_requirements.txt https://raw.githubusercontent.com/yoshiko2/Movie_Data_Capture/$MDC_REQUIREMENTS_SOURCE_VERSION/requirements.txt && \
pip install -r mdc_requirements.txt

ARG PYINSTALLER_SOURCE_VERISON
ENV PYINSTALLER_SOURCE_VERISON=${PYINSTALLER_SOURCE_VERISON:-669313ba4c5c1403ebeb335c35cb68c8c6ba5dd4}

# build bootloader for alpine
RUN cd /tmp && \
wget -q -nc --show-progress --progress=bar:force:noscroll -O /tmp/pyinstaller-$PYINSTALLER_SOURCE_VERISON.tar.gz https://github.com/pyinstaller/pyinstaller/archive/$PYINSTALLER_SOURCE_VERISON.tar.gz && \
tar zxvf /tmp/pyinstaller-$PYINSTALLER_SOURCE_VERISON.tar.gz && \
rm /tmp/pyinstaller-$PYINSTALLER_SOURCE_VERISON.tar.gz && \
mv pyinstaller-$PYINSTALLER_SOURCE_VERISON pyinstaller && \
cd /tmp/pyinstaller/bootloader && \
CFLAGS="-Wno-stringop-overflow -Wno-stringop-truncation" python ./waf configure --no-lsb all && \
pip install .. && \
rm -Rf /tmp/pyinstaller

ADD ./root /pyinstaller
RUN chmod a+x /pyinstaller/*

RUN git clone --depth=1 -b ${MDC_VERSION} https://github.com/yoshiko2/Movie_Data_Capture.git /tmp/src
RUN cd /tmp/src && pip install -r requirements.txt
# get mdc source code
ARG MDC_SOURCE_VERSION
ENV MDC_SOURCE_VERSION=${MDC_SOURCE_VERSION:-c0fab96191b882ebbd7acaeb3c81d6f60e1d4206}

RUN cd /tmp && \
wget -q -nc --show-progress --progress=bar:force:noscroll -O /tmp/mdc-$MDC_SOURCE_VERSION.tar.gz https://github.com/yoshiko2/Movie_Data_Capture/archive/$MDC_SOURCE_VERSION.tar.gz && \
tar zxvf /tmp/mdc-$MDC_SOURCE_VERSION.tar.gz && \
rm /tmp/mdc-$MDC_SOURCE_VERSION.tar.gz && \
mv Movie_Data_Capture-$MDC_SOURCE_VERSION mdc

RUN \
cd /tmp/src && \
# build mdc
RUN cd /tmp/mdc && \
/pyinstaller/pyinstaller.sh \
--onefile Movie_Data_Capture.py \
--hidden-import ADC_function.py \
Expand All @@ -58,13 +87,12 @@ RUN \
--add-data "$(python -c 'import opencc as _; print(_.__path__[0])' | tail -n 1):opencc" \
--add-data "$(python -c 'import face_recognition_models as _; print(_.__path__[0])' | tail -n 1):face_recognition_models"

FROM alpine:3.15
# build done

FROM ghcr.io/vergilgao/alpine-baseimage

RUN apk --update --no-cache add \
ca-certificates \
coreutils \
libxcb \
shadow \
tzdata
libxcb

ARG BUILD_DATE
ARG VERSION
Expand All @@ -75,22 +103,22 @@ LABEL build_from="https://github.com/yoshiko2/Movie_Data_Capture"
LABEL org.opencontainers.image.source="https://github.com/VergilGao/docker-mdc"

ENV TZ="Asia/Shanghai"
ENV PUID=99
ENV PGID=100
ENV UID=99
ENV GID=100
ENV UMASK=000

ADD docker-entrypoint.sh docker-entrypoint.sh

RUN chmod +x docker-entrypoint.sh && \
mkdir /app && \
mkdir -p /app && \
mkdir -p /data && \
mkdir -p /config && \
useradd -d /config -s /bin/sh alpha && \
chown -R alpha /config && \
chown -R alpha /data
useradd -d /config -s /bin/sh mdc && \
chown -R mdc /config && \
chown -R mdc /data

COPY --from=build-stage /tmp/src/dist/Movie_Data_Capture /app
#nightly COPY --from=build-stage /tmp/src/config.ini /config/mdc.ini
COPY --from=build-stage /tmp/mdc/dist/Movie_Data_Capture /app
COPY --from=build-stage /tmp/mdc/config.ini /app/config.template

VOLUME [ "/data", "/config" ]

Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

Loading

0 comments on commit 2679b2a

Please sign in to comment.