diff --git a/Dockerfile b/Dockerfile index 98613e87d..7d072711a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,7 +39,8 @@ RUN yarn install # Ruby dependencies COPY Gemfile Gemfile.lock ./ RUN bundle config --global frozen 1 && \ - bundle install --path=vendor/bundle --without development test \ + bundle config set without 'development test' && \ + bundle install --path=vendor/bundle \ --jobs `expr $(cat /proc/cpuinfo | grep -c "cpu cores") - 1` --retry 3 COPY . $APP_ROOT @@ -63,7 +64,7 @@ ARG REPLACE_CHINA_MIRROR="true" ARG ORIGINAL_REPO_URL="http://dl-cdn.alpinelinux.org" ARG MIRROR_REPO_URL="https://mirrors.tuna.tsinghua.edu.cn" ARG RUBYGEMS_SOURCE="https://gems.ruby-china.com/" -ARG PACKAGES="tzdata curl shadow logrotate imagemagick imagemagick-dev postgresql-dev postgresql-client openssl openssl-dev" +ARG PACKAGES="tzdata curl logrotate imagemagick imagemagick-dev postgresql-dev postgresql-client openssl openssl-dev" ARG RUBY_GEMS="bundler" ARG APP_ROOT=/app ARG S6_OVERLAY_VERSION="2.0.0.1" @@ -96,14 +97,19 @@ RUN set -ex && \ fi && \ apk --update --no-cache add $PACKAGES && \ curl -L -s https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-amd64.tar.gz | tar xvzf - -C / && \ - gem install $RUBY_GEMS && \ - adduser -D -u 911 -g zealot -h /app -s /sbin/nologin zealot + gem install $RUBY_GEMS WORKDIR $APP_ROOT COPY docker/rootfs / COPY --from=builder $APP_ROOT $APP_ROOT +# Remove unnecessary files +RUN cd /app/vendor/bundle/ruby/2.6.0 && \ + rm -rf cache/*.gem && \ + find gems/ -name "*.c" -delete && \ + find gems/ -name "*.o" -delete + EXPOSE 3000 ENTRYPOINT ["/init"] diff --git a/docker/rootfs/etc/cont-init.d/00-adduser b/docker/rootfs/etc/cont-init.d/00-adduser deleted file mode 100644 index 09a93fd45..000000000 --- a/docker/rootfs/etc/cont-init.d/00-adduser +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/with-contenv sh - -PUID=${PUID:-911} -PGID=${PGID:-911} - -groupmod -o -g "$PGID" zealot -usermod -o -u "$PUID" zealot - -echo " -------------------------------------- -GID/UID -------------------------------------- -User uid: $(id -u zealot) -User gid: $(id -g zealot) -------------------------------------- -" \ No newline at end of file diff --git a/docker/rootfs/etc/cont-init.d/12-logrotate b/docker/rootfs/etc/cont-init.d/12-logrotate index 9aeb21cb0..c3641db1c 100755 --- a/docker/rootfs/etc/cont-init.d/12-logrotate +++ b/docker/rootfs/etc/cont-init.d/12-logrotate @@ -2,13 +2,13 @@ if [[ ! -f /mnt/config/etc/logrotate.conf ]]; then if [[ ! -d /mnt/config/etc ]]; then - s6-setuidgid guardian mkdir -p /mnt/config/etc + mkdir -p /mnt/config/etc fi - s6-setuidgid guardian cp /etc/logrotate.conf /mnt/config/etc/logrotate.conf + cp /etc/logrotate.conf /mnt/config/etc/logrotate.conf fi if [[ ! -d /mnt/config/etc/logrotate.d ]]; then - s6-setuidgid guardian mkdir -p /mnt/config/etc/logrotate.d - s6-setuidgid guardian cp -n /etc/logrotate.d/* /mnt/config/etc/logrotate.d/ + mkdir -p /mnt/config/etc/logrotate.d + cp -n /etc/logrotate.d/* /mnt/config/etc/logrotate.d/ fi \ No newline at end of file diff --git a/docker/rootfs/etc/cont-init.d/20-init-zealot b/docker/rootfs/etc/cont-init.d/20-init-zealot index 7bc3bb06b..0887a4183 100644 --- a/docker/rootfs/etc/cont-init.d/20-init-zealot +++ b/docker/rootfs/etc/cont-init.d/20-init-zealot @@ -3,23 +3,23 @@ cd /app # Clear pid if unexpected exception exit -s6-setuidgid zealot rm -f tmp/pids/.pid -s6-setuidgid zealot mkdir -p tmp/pids tmp/cache tmp/uploads tmp/sockets log +rm -f tmp/pids/.pid +mkdir -p tmp/pids tmp/cache tmp/uploads tmp/sockets log # Updating assets if [ -d "new_public" ]; then echo "Zealot updating public ..." for x in public/*; do if [ -z $(echo "$x" | grep uploads) ]; then - s6-setuidgid zealot rm -rf "$x" + rm -rf "$x" fi done for x in new_public/*; do if [ -z $(echo "$x" | grep uploads) ]; then - s6-setuidgid zealot mv "$x" "public" + mv "$x" "public" fi done - s6-setuidgid zealot rm -rf new_public + rm -rf new_public fi \ No newline at end of file diff --git a/docker/rootfs/etc/fix-attrs.d/20-zealot-app-dir b/docker/rootfs/etc/fix-attrs.d/20-zealot-app-dir deleted file mode 100644 index 88d03c60c..000000000 --- a/docker/rootfs/etc/fix-attrs.d/20-zealot-app-dir +++ /dev/null @@ -1,3 +0,0 @@ -/app true zealot,911:911 0644 0755 -/app/bin true zealot,911:911 0755 0755 -/app/vendor true zealot,911:911 0755 0755 \ No newline at end of file