Improve dockerfile

pull/500/head
Chocobozzz 2018-04-16 18:44:57 +02:00
parent 94ff4c2335
commit 4aeb67a569
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 25 additions and 14 deletions

View File

@ -2,9 +2,11 @@
*.md *.md
.git .git
.github .github
config
support/doc support/doc
support/nginx support/nginx
support/systemd support/systemd
support/docker/*/Dockerfile.* support/docker/*/Dockerfile.*
support/docker/*/*.yml support/docker/*/*.yml
storage
node_modules
client/node_modules

View 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 "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"; \ wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
export GNUPGHOME="$(mktemp -d)"; \ 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; \ gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \ rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \
chmod +x /usr/local/bin/gosu; \ chmod +x /usr/local/bin/gosu; \
@ -41,13 +47,13 @@ RUN set -ex; \
\ \
apt-get purge -y --auto-remove wget 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 # Install PeerTube
USER peertube
WORKDIR /app WORKDIR /app
RUN chown peertube:peertube /app
COPY --chown=peertube:peertube . ./
USER peertube
RUN yarn install --pure-lockfile \ RUN yarn install --pure-lockfile \
&& npm run build && npm run build
@ -58,11 +64,11 @@ ENV NODE_ENV production
ENV NODE_CONFIG_DIR /app/support/docker/production/config ENV NODE_CONFIG_DIR /app/support/docker/production/config
USER root USER root
RUN mkdir /data && chown peertube:peertube /data RUN mkdir /data
VOLUME /data VOLUME /data
COPY docker-entrypoint.sh /usr/local/bin/ COPY ./support/docker/production/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"] ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
# Run the application # Run the application
CMD ["npm", "start"] CMD ["npm", "start"]

View File

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

View File

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