Browse Source

Improve dockerfile

Chocobozzz 1 year ago
parent
commit
4aeb67a569
No account linked to committer's email address

+ 3
- 1
.dockerignore View File

@@ -2,9 +2,11 @@
2 2
 *.md
3 3
 .git
4 4
 .github
5
-config
6 5
 support/doc
7 6
 support/nginx
8 7
 support/systemd
9 8
 support/docker/*/Dockerfile.*
10 9
 support/docker/*/*.yml
10
+storage
11
+node_modules
12
+client/node_modules

+ 15
- 9
support/docker/production/Dockerfile.stretch View File

@@ -33,7 +33,13 @@ RUN set -ex; \
33 33
     wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
34 34
     wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
35 35
     export GNUPGHOME="$(mktemp -d)"; \
36
-    gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
36
+    for server in $(shuf -e ha.pool.sks-keyservers.net \
37
+                            hkp://p80.pool.sks-keyservers.net:80 \
38
+                            keyserver.ubuntu.com \
39
+                            hkp://keyserver.ubuntu.com:80 \
40
+                            pgp.mit.edu) ; do \
41
+        gpg --keyserver "$server" --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 && break || : ; \
42
+    done; \
37 43
     gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
38 44
     rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \
39 45
     chmod +x /usr/local/bin/gosu; \
@@ -41,13 +47,13 @@ RUN set -ex; \
41 47
     \
42 48
     apt-get purge -y --auto-remove wget
43 49
 
44
-# Download the latest version
45
-RUN git clone https://github.com/Chocobozzz/PeerTube /app \
46
-    && chown -R peertube:peertube /app
47
-
48 50
 # Install PeerTube
49
-USER peertube
50 51
 WORKDIR /app
52
+RUN chown peertube:peertube /app
53
+
54
+COPY --chown=peertube:peertube . ./
55
+
56
+USER peertube
51 57
 
52 58
 RUN yarn install --pure-lockfile \
53 59
     && npm run build
@@ -58,11 +64,11 @@ ENV NODE_ENV production
58 64
 ENV NODE_CONFIG_DIR /app/support/docker/production/config
59 65
 
60 66
 USER root
61
-RUN mkdir /data && chown peertube:peertube /data
67
+RUN mkdir /data
62 68
 VOLUME /data
63 69
 
64
-COPY docker-entrypoint.sh /usr/local/bin/
65
-ENTRYPOINT ["docker-entrypoint.sh"]
70
+COPY ./support/docker/production/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
71
+ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
66 72
 
67 73
 # Run the application
68 74
 CMD ["npm", "start"]

+ 3
- 0
support/docker/production/docker-compose.yml View File

@@ -28,6 +28,9 @@ services:
28 28
       traefik.enable: "true"
29 29
       traefik.frontend.rule: "Host:${PEERTUBE_HOSTNAME}"
30 30
       traefik.port: "9000"
31
+    # If you don't want to use a reverse proxy (not suitable for production!)
32
+    # ports:
33
+      # - "80:9000"
31 34
     volumes:
32 35
       - ./data:/data
33 36
     depends_on:

+ 4
- 4
support/docker/production/docker-entrypoint.sh View File

@@ -4,13 +4,13 @@ set -e
4 4
 # first arg is `-f` or `--some-option`
5 5
 # or first arg is `something.conf`
6 6
 if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then
7
-        set -- npm "$@"
7
+    set -- npm "$@"
8 8
 fi
9 9
 
10 10
 # allow the container to be started with `--user`
11
-if [ "$1" = 'npm' -a "$(id -u)" = '0' ]; then
12
-        chown -R peertube: /data
13
-        exec gosu peertube "$0" "$@"
11
+if [ "$1" = 'npm' -a "$(id -u)" != '0' ]; then
12
+    chown -R peertube:peertube /data
13
+    exec gosu peertube "$0" "$@"
14 14
 fi
15 15
 
16 16
 exec "$@"

Loading…
Cancel
Save