-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-alpine
66 lines (55 loc) · 2.01 KB
/
Dockerfile-alpine
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
ARG ALPINE_RUBY_VERSION=2.7.3
ARG BUILD_BASE_SHA1
ARG BUNDLER_VERSION=2.2.22
# Should exists for alpine, see https://unofficial-builds.nodejs.org/download/release/
ARG NODE_VERSION=v16.13.0
########################################################################
# Dependancy layer
########################################################################
FROM git.octree.ch:4567/decidim/ocsin/releases:build-base-${BUILD_BASE_SHA1} AS dependancy
########################################################################
# Final layer
########################################################################
FROM ruby:${ALPINE_RUBY_VERSION}-alpine
LABEL maintainer="[email protected]"
ARG ALPINE_RUBY_VERSION
ARG BUNDLER_VERSION
ENV RAILS_ENV=production \
RACK_ENV=production \
TZ=Europe/Zurich \
LANG=C.UTF-8 \
RAILS_SERVE_STATIC_FILES=false \
BUNDLER_VERSION=$BUNDLER_VERSION \
RAILS_ROOT=/home/decidim/app
ENV PATH=$PATH:$RAILS_ROOT/bin
RUN apk update && \
apk upgrade && \
gem update --system && \
gem install bundler --version "$BUNDLER_VERSION" && \
apk add --no-cache \
postgresql-dev \
tzdata \
imagemagick \
bash \
p7zip \
vim \
&& rm -rf /var/cache/apk/*
RUN mkdir -p $RAILS_ROOT/lib/seven_zip_ruby && \
ln -s /usr/lib/p7zip/7z.so $RAILS_ROOT/lib/seven_zip_ruby/7z.so
# Add imagemagick policy
COPY ./.docker/imagemagick-policy.xml /etc/ImageMagick-7/policy.xml
RUN bundle config set without 'development test'
# Create system user to run as non-root.
ONBUILD COPY .user.conf .
ONBUILD RUN source .user.conf && addgroup -S decidim -g $GROUP_UID && \
adduser -S -g '' -u $USER_UID -G decidim decidim && \
rm .user.conf
# Copy app & gems
COPY --from=dependancy /usr/local/bundle/ /usr/local/bundle/
# Switch to non-root system user
ONBUILD USER decidim
ONBUILD WORKDIR $RAILS_ROOT
# Define bash as the default shell
SHELL ["/bin/bash", "-l", "-c"]
ENTRYPOINT [".docker/entrypoint.sh"]
CMD ["bundle", "exec", "rails", "server", "puma"]