Skip to content

Instantly share code, notes, and snippets.

@pgaertig
Created April 4, 2018 20:28
Show Gist options
  • Save pgaertig/5f5c6cd96fec2f089ac2b4f743a6eb8e to your computer and use it in GitHub Desktop.
Save pgaertig/5f5c6cd96fec2f089ac2b4f743a6eb8e to your computer and use it in GitHub Desktop.
KP Dockerfile
#!/usr/bin/dumb-init /bin/bash
if [ -d "$CDN_DIR" ]; then
echo "Syncing CDN"
cp -fr /home/app/public/* $CDN_DIR
chown -R app:www-data $CDN_DIR/*
chmod -R "o-rx" $CDN_DIR/*
fi
cd /home/app
HOME=/home/app
exec chroot --userspec=app:www-data --skip-chdir / puma -b tcp://${RAILS_IP:-127.0.0.1}:${RAILS_PORT:-3000} -e ${RAILS_ENV:-development}
FROM debian:stretch-slim
ENV RAILS_ENV=production TERM=xterm
ADD Gemfile Gemfile.lock package.json /home/app/
RUN (echo "deb http://deb.debian.org/debian/ stretch non-free contrib" >> /etc/apt/sources.list) && \
apt-get -qq update && \
apt-get install -y --no-install-recommends gnupg2 ca-certificates git curl ruby2.3 ruby-dev build-essential \
libpq-dev libpq5 libxml2 zlib1g-dev dumb-init libfontconfig ttf-mscorefonts-installer procps bzip2 && \
(curl -sL https://deb.nodesource.com/setup_8.x | bash - ) && \
gem install bundler --no-ri --no-rdoc && \
groupadd -g 1000 -o app && \
useradd --shell /usr/sbin/nologin -u 1000 -d "/home/app" -o -c "" -g 1000 -G www-data app && \
mkdir -p /home/app && \
mkdir -p /home/app/.phantomjs/2.1.1/x86_64-linux && \
curl -L https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 \
| tar xj --strip-components=1 -C /home/app/.phantomjs/2.1.1/x86_64-linux && \
cd /home/app && \
DOCKERBUILD=1 bundle install --no-cache --system && \
rm -rf /var/lib/gems/2.3.0/cache /root/.bundle/cache && \
apt-get -yq purge python3.5 build-essential ruby-dev libpq-dev && apt-get -yq autoclean && apt-get -yq autoremove && \
rm -rf /usr/src /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc /usr/share/doc-base /usr/share/man /usr/share/locale /usr/share/zoneinfo /usr/src && \
rm -rf /usr/lib/node_modules
ADD . /home/app
# Update full dependencies
RUN cd /home/app && \
bundle install --local --no-cache --system && \
cp /home/app/config/system/100-phantomjs-kerning-fix.conf /etc/fonts/conf.d/ && \
apt-get -yq update && apt-get install -y --no-install-recommends nodejs && \
npm install -g yarn && \
yarn install --non-interactive && \
RAILS_ENV=production rake assets:precompile && \
apt-get -yq purge nodejs && apt-get -yq autoclean && apt-get -yq autoremove && \
rm -rf /usr/src /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc /usr/share/doc-base /usr/share/man /usr/share/locale /usr/share/zoneinfo /usr/src && \
rm -rf /usr/lib/node_modules node_modules tmp/cache/assets /root/.bundle/cache
CMD ["/home/app/bin/docker_run.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment