Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

Commit

Permalink
feat(dockerfile): 迅雷镜像构建和使用
Browse files Browse the repository at this point in the history
  • Loading branch information
zjZSTU committed Oct 10, 2019
1 parent 61309cb commit 3c1ac37
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
24 changes: 24 additions & 0 deletions dockerfiles/thunder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM zjzstu/deepin-wine:latest
LABEL maintainer "zhujian <zjzstu@github.com>"

WORKDIR /app
RUN set -eux && \
apt-get update && \
apt-get install -y wget ttf-wqy-microhei gosu dbus && \
gosu nobody true && \
wget https://mirrors.aliyun.com/deepin/pool/non-free/d/deepin.com.thunderspeed/deepin.com.thunderspeed_7.10.35.366deepin18_i386.deb && \
useradd -s /bin/bash -m user && \
chown -R user:user /app && \
dpkg -i *.deb && \
rm -f *.deb && \
apt-get autoclean -y && apt-get clean -y && \
find /var/lib/apt/lists -type f -delete && \
find /var/cache -type f -delete && \
find /var/log -type f -delete && \
find /usr/share/doc -type f -delete && \
find /usr/share/man -type f -delete

COPY docker-entrypoint.sh ./
RUN chmod a+x docker-entrypoint.sh && \
chown user:user docker-entrypoint.sh
ENTRYPOINT ["/app/docker-entrypoint.sh"]
28 changes: 28 additions & 0 deletions dockerfiles/thunder/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

if [ "$(id -u)" -eq '0' ]
then
UID=${UID:-9001}
GID=${GID:-9001}
AUDIO_GID=${AUDIO_GID:-9002}
VIDEO_GID=${VIDEO_GID:-9003}
id
usermod -u ${UID} -g ${GID} -a -G root,${AUDIO_GID},${VIDEO_GID} user > /dev/null 2>&1

source dbus start > /dev/null 2>&1
export HOME=/home/user
chown -R ${UID}:${GID} ${HOME} > /dev/null 2>&1
exec gosu user "$0" "$@"
fi

APP="ThunderSpeed"
APP_NAME="Thunder.exe"

/opt/deepinwine/apps/Deepin-${APP}/run.sh > /dev/null 2>&1
sleep 30s

while test -n "`pidof ${APP_NAME}`"
do
sleep 1s
done
exit "$?"
57 changes: 57 additions & 0 deletions dockerfiles/thunder/thunder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

APP="ThunderSpeed"
COMMAND="/opt/deepinwine/apps/Deepin-${APP}/run.sh"
CONTAINER_NAME="thunder"
IMAGE_NAME="zjzstu/thunder:latest"

HOST_FILE_DIR="${HOME}/deepin-wine/${APP} Files"
CONTAINER_FILE_DIR="/home/user/${APP} Files"

# 启动wechat镜像
function startup()
{
docker run \
--device=/dev/snd:/dev/snd \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix${DISPLAY} \
-e AUDIO_GID=`getent group audio | cut -d: -f3` \
-e VIDEO_GID=`getent group video | cut -d: -f3` \
-e GID=`id -g` \
-e UID=`id -u` \
-e XMODIFIERS="@im=fcitx" \
-e QT_IM_MODULE="fcitx" \
-e GTK_IM_MODULE="fcitx" \
-v "${HOST_FILE_DIR}":"${CONTAINER_FILE_DIR}" \
--name ${CONTAINER_NAME} \
-d ${IMAGE_NAME} > /dev/null 2>&1
}

function run()
{
xhost + > /dev/null 2>&1

START=$(docker ps -q --filter="name=${CONTAINER_NAME}")
STOP=$(docker ps -aq --filter="name=${CONTAINER_NAME}")

echo $START
echo $STOP
if [ -n "${START}" ]
then
docker exec -d -u user $START ${COMMAND} > /dev/null 2>&1
elif [ -n "${STOP}" ]
then
docker restart ${STOP} > /dev/null 2>&1
else
echo "startup"
startup
fi
}

function main()
{
run
exit "$?"
}

main

0 comments on commit 3c1ac37

Please sign in to comment.