Skip to content

Commit

Permalink
refactor(docker): 暂不支持自定义 uid 和 gid
Browse files Browse the repository at this point in the history
  • Loading branch information
icyleaf committed Jul 21, 2020
1 parent b00a55a commit 1c67256
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 32 deletions.
14 changes: 10 additions & 4 deletions Dockerfile
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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"]
16 changes: 0 additions & 16 deletions docker/rootfs/etc/cont-init.d/00-adduser

This file was deleted.

8 changes: 4 additions & 4 deletions docker/rootfs/etc/cont-init.d/12-logrotate
Expand Up @@ -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
10 changes: 5 additions & 5 deletions docker/rootfs/etc/cont-init.d/20-init-zealot
Expand Up @@ -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
3 changes: 0 additions & 3 deletions docker/rootfs/etc/fix-attrs.d/20-zealot-app-dir

This file was deleted.

0 comments on commit 1c67256

Please sign in to comment.