]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Improve dockerfile
authorChocobozzz <me@florianbigard.com>
Mon, 16 Apr 2018 16:44:57 +0000 (18:44 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 16 Apr 2018 16:44:57 +0000 (18:44 +0200)
.dockerignore
support/docker/production/Dockerfile.stretch
support/docker/production/docker-compose.yml
support/docker/production/docker-entrypoint.sh

index 1d1cf894acde69246b03cf3bdf602d2f287f017b..9a32da269aa67ce86830334c6751850293b9663f 100644 (file)
@@ -2,9 +2,11 @@
 *.md
 .git
 .github
-config
 support/doc
 support/nginx
 support/systemd
 support/docker/*/Dockerfile.*
 support/docker/*/*.yml
+storage
+node_modules
+client/node_modules
index bf2bae510dad1352c33a38d34f3325cf1ad95825..5bb67f81619700b4ef5ae32178b51170a1d0fc3e 100644 (file)
@@ -33,7 +33,13 @@ RUN set -ex; \
     wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
     wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
     export GNUPGHOME="$(mktemp -d)"; \
-    gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
+    for server in $(shuf -e ha.pool.sks-keyservers.net \
+                            hkp://p80.pool.sks-keyservers.net:80 \
+                            keyserver.ubuntu.com \
+                            hkp://keyserver.ubuntu.com:80 \
+                            pgp.mit.edu) ; do \
+        gpg --keyserver "$server" --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 && break || : ; \
+    done; \
     gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
     rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \
     chmod +x /usr/local/bin/gosu; \
@@ -41,13 +47,13 @@ RUN set -ex; \
     \
     apt-get purge -y --auto-remove wget
 
-# Download the latest version
-RUN git clone https://github.com/Chocobozzz/PeerTube /app \
-    && chown -R peertube:peertube /app
-
 # Install PeerTube
-USER peertube
 WORKDIR /app
+RUN chown peertube:peertube /app
+
+COPY --chown=peertube:peertube . ./
+
+USER peertube
 
 RUN yarn install --pure-lockfile \
     && npm run build
@@ -58,11 +64,11 @@ ENV NODE_ENV production
 ENV NODE_CONFIG_DIR /app/support/docker/production/config
 
 USER root
-RUN mkdir /data && chown peertube:peertube /data
+RUN mkdir /data
 VOLUME /data
 
-COPY docker-entrypoint.sh /usr/local/bin/
-ENTRYPOINT ["docker-entrypoint.sh"]
+COPY ./support/docker/production/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
+ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
 
 # Run the application
 CMD ["npm", "start"]
index f273915b972c523078450cd60ca06d768ec01724..ac0a3543b69d91c2ae79054c50f4ec99e0758e59 100644 (file)
@@ -28,6 +28,9 @@ services:
       traefik.enable: "true"
       traefik.frontend.rule: "Host:${PEERTUBE_HOSTNAME}"
       traefik.port: "9000"
+    # If you don't want to use a reverse proxy (not suitable for production!)
+    # ports:
+      # - "80:9000"
     volumes:
       - ./data:/data
     depends_on:
index 79f0e60f65dfc304e342575944fc70113971b10a..4099a19847f7e15168aa920a7c34b38bdfd61773 100755 (executable)
@@ -4,13 +4,13 @@ set -e
 # first arg is `-f` or `--some-option`
 # or first arg is `something.conf`
 if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then
-        set -- npm "$@"
+    set -- npm "$@"
 fi
 
 # allow the container to be started with `--user`
-if [ "$1" = 'npm' -a "$(id -u)" = '0' ]; then
-        chown -R peertube: /data
-        exec gosu peertube "$0" "$@"
+if [ "$1" = 'npm' -a "$(id -u)" != '0' ]; then
+    chown -R peertube:peertube /data
+    exec gosu peertube "$0" "$@"
 fi
 
 exec "$@"