diff --git a/.drone.yml b/.drone.yml index 64dbe87..0fa2ae5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,11 +1,18 @@ pipeline: - build: + build-debian: image: plugins/docker registry: registry.dryusdan.fr repo: registry.dryusdan.fr/dryusdan/peertube dockerfile: Dockerfile.debian secrets: [ docker_username, docker_password ] + build-alpine: + image: plugins/docker + registry: registry.dryusdan.fr + repo: registry.dryusdan.fr/dryusdan/peertube:alpine + dockerfile: Dockerfile.alpine + secrets: [ docker_username, docker_password ] + push: image: appleboy/drone-git-push branch: master diff --git a/Dockerfile.alpine b/Dockerfile.alpine new file mode 100644 index 0000000..a2c05b4 --- /dev/null +++ b/Dockerfile.alpine @@ -0,0 +1,52 @@ +FROM alpine:3.7 + +ENV UID=991 GID=991 \ + HTTPS=false \ + HOSTNAME=peertube.localhost \ + PORT=80 \ + DATABASE_HOST=localhost \ + DATABASE_PORT=5432 \ + DATABASE_USERNAME=peertube \ + DATABASE_PASSWORD=peertube \ + ADMIN_EMAIL=admin@domain.local \ + SIGNUP_ENABLE=false \ + TRANSCODING_ENABLE=false \ + TRANSCODING_THREADS=2 \ + BODY_SIZE=100M \ + CACHE_SIZE=100 \ + SIGNUP_LIMIT=10 \ + VIDEO_QUOTA=-1 \ + RESOLUTION_280=true \ + RESOLUTION_360=true \ + RESOLUTION_480=true \ + RESOLUTION_720=true \ + RESOLUTION_1080=true \ + DEBIAN_FRONTEND=noninteractiv + +RUN addgroup -g 991 peertube && useradd -u 991 -G 991 -h /home/peertube \ + && apk -U add curl ffmpeg openssl git nginx yarn nodejs build-base su-exec shadow \ + && git clone --branch ${PEERTUBE_VER} https://github.com/Chocobozzz/PeerTube /PeerTube \ + && echo "****** chown ******" \ + && chown -R peertube:peertube PeerTube \ + && cd /PeerTube \ + && echo "****** run npm install as user ******" \ + && su-exec peertube:peertube "cd /PeerTube && npm install" \ + && echo "****** run yarn install as user ******" \ + && su-exec peertube:peertube "cd /PeerTube && yarn install" \ + && echo "****** run npm run build as user ******" \ + && su-exec peertube:peertube "cd /PeerTub && npm run build" \ + && apk del git build-base \ + && rm -rf /tmp/* /PeerTube.git /var/cache/apk/* + +EXPOSE 8080 + +COPY rootfs / + +RUN chmod +x /usr/local/bin/startup-alpine + +WORKDIR /PeerTube/ + +VOLUME ["/PeerTube/certs", "/PeerTube/videos", "/PeerTube/logs", "/PeerTube/previews", "/PeerTube/thumbnails", "/PeerTube/torrents"] + +ENTRYPOINT ["/usr/local/bin/startup-alpine"] + diff --git a/rootfs/usr/local/bin/startup-alpine b/rootfs/usr/local/bin/startup-alpine new file mode 100755 index 0000000..0ec0fe1 --- /dev/null +++ b/rootfs/usr/local/bin/startup-alpine @@ -0,0 +1,38 @@ +#!/bin/sh + +#groupadd -g ${GID} peertube && useradd -u ${UID} -M -g ${GID} peertube + +usermod -u ${GID} peertube +groupmod -g ${UID} peertube + +sed -i -e 's||'${HTTPS}'|' \ + -e 's||'${HOSTNAME}'|' \ + -e 's||'${PORT}'|' \ + -e 's||'${DATABASE_HOST}'|' \ + -e 's||'${DATABASE_PORT}'|' \ + -e 's||'${DATABASE_USERNAME}'|' \ + -e 's||'${DATABASE_PASSWORD}'|' \ + -e 's||'${ADMIN_EMAIL}'|' \ + -e 's||'${SIGNUP_ENABLE}'|' \ + -e 's||'${TRANSCODING_ENABLE}'|' \ + -e 's||'${TRANSCODING_THREADS}'|' \ + -e 's||'${CACHE_SIZE}'|' \ + -e 's||'${SIGNUP_LIMIT}'|' \ + -e 's||'${VIDEO_QUOTA}'|' \ + -e 's||'${RESOLUTION_280}'|' \ + -e 's||'${RESOLUTION_360}'|' \ + -e 's||'${RESOLUTION_480}'|' \ + -e 's||'${RESOLUTION_720}'|' \ + -e 's||'${RESOLUTION_1080}'|' /PeerTube/config/production.yaml + +sed -i -e 's||'${BODY_SIZE}'|' /etc/nginx/sites-enabled/peertube.conf + +chown -R $UID:$GID /home/peertube +chown -R $UID:$GID /PeerTube + +nginx +if [ $# -eq 0 ]; then + exec su-exec peertube:peertube NODE_ENV=production npm start +else + exec su-exec peertube:peertube NODE_ENV=production npm $# +fi