Spotter-VM/ccleanup/Dockerfile

52 lines
1.6 KiB
Docker
Raw Normal View History

FROM ruby
2017-12-25 11:43:06 +01:00
MAINTAINER Disassembler <disassembler@dasm.cz>
2018-01-08 21:04:35 +01:00
RUN \
# Install NodeJS runtime
apk --no-cache add nodejs paxctl \
# Fix grsec attributes to loosen memory protection restrictions
&& paxctl -cm /usr/bin/node \
# Cleanup
&& apk --no-cache del paxctl
2018-01-08 21:04:35 +01:00
2017-12-25 11:43:06 +01:00
RUN \
# Install runtime dependencies
2018-01-08 21:04:35 +01:00
apk --no-cache add libpq libxml2 libxslt tzdata
ENV RAILS_ENV production
2018-01-08 21:04:35 +01:00
RUN \
2017-12-25 11:43:06 +01:00
# Install build dependencies
2018-01-08 21:04:35 +01:00
apk --no-cache add --virtual .deps build-base git libxml2-dev libxslt-dev linux-headers postgresql-dev yarn zlib-dev \
2017-12-25 11:43:06 +01:00
# Clone CrisisCleanup
2018-03-25 14:07:25 +02:00
&& git clone --depth 1 https://github.com/CrisisCleanup/crisiscleanup /srv/ccleanup \
2017-12-25 11:43:06 +01:00
# Hackfix ruby dependency versions
2018-03-25 14:07:25 +02:00
&& sed -i 's/2\.2\.5/2.3.6/' /srv/ccleanup/Gemfile \
&& sed -i 's/rdoc (4\.2\.0)/rdoc (4.3.0)/' /srv/ccleanup/Gemfile.lock \
2017-12-25 11:43:06 +01:00
# Install Ruby and NodeJS dependencies
2018-03-25 14:07:25 +02:00
&& cd /srv/ccleanup \
2017-12-25 11:43:06 +01:00
&& bundle config build.nokogiri --use-system-libraries \
&& bundle install \
&& npm install \
&& yarn \
# Create CrisisCleanup secret
2018-03-25 14:07:25 +02:00
&& echo -e "production:\n secret_key_base: $(rake secret)" >/srv/ccleanup/config/secrets.yml \
2017-12-25 11:43:06 +01:00
# Generate static resources
&& rake assets:precompile \
# Create OS user
2018-03-25 14:07:25 +02:00
&& addgroup -S -g 8005 ccleanup \
&& adduser -S -u 8005 -h /srv/ccleanup -s /bin/false -g ccleanup -G ccleanup ccleanup \
&& chown -R ccleanup:ccleanup /srv/ccleanup \
2017-12-25 11:43:06 +01:00
# Cleanup
&& apk --no-cache del .deps \
2018-03-25 14:07:25 +02:00
&& find /srv/ccleanup -name '.git*' -exec rm -rf {} + \
2017-12-25 11:43:06 +01:00
&& rm -rf /usr/local/share/.cache \
&& rm -rf /root/.bundle /root/.config /root/.npm
2017-12-25 11:43:06 +01:00
2018-03-25 14:07:25 +02:00
VOLUME ["/srv/ccleanup/config"]
EXPOSE 8080
2017-12-25 11:43:06 +01:00
2018-03-25 14:07:25 +02:00
USER ccleanup
WORKDIR /srv/ccleanup
2017-12-25 11:43:06 +01:00
CMD ["rails", "server"]