forked from ukparliament/parliament.uk-prototype
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
63 lines (53 loc) · 1.63 KB
/
Dockerfile
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
FROM ruby:2-alpine
# Add command line argument variables used to cusomise the image at build-time.
ARG PARLIAMENT_BASE_URL
ARG PARLIAMENT_AUTH_TOKEN
ARG BANDIERA_URL
ARG GTM_KEY
ARG ASSET_LOCATION_URL
ARG SECRET_KEY_BASE
ARG RACK_ENV=production
# Add Gemfiles.
ADD Gemfile /app/
ADD Gemfile.lock /app/
# Set the working DIR.
WORKDIR /app
# Install system and application dependencies.
RUN apk --update add --virtual build-dependencies build-base ruby-dev && \
gem install bundler --no-ri --no-rdoc && \
echo "Environment (RACK_ENV): $RACK_ENV" && \
if [ "$RACK_ENV" == "production" ]; then \
bundle install --without development test --path vendor/bundle; \
apk del build-dependencies; \
else \
bundle install --path vendor/bundle; \
fi
# Copy the application onto our image.
ADD . /app
# Make sure our user owns the application directory.
RUN if [ "$RACK_ENV" == "production" ]; then \
chown -R nobody:nogroup /app; \
else \
chown -R nobody:nogroup /app /usr/local/bundle; \
fi
# Set up our user and environment
USER nobody
ENV PARLIAMENT_BASE_URL $PARLIAMENT_BASE_URL
ENV PARLIAMENT_AUTH_TOKEN $PARLIAMENT_AUTH_TOKEN
ENV BANDIERA_URL $BANDIERA_URL
ENV GTM_KEY $GTM_KEY
ENV ASSET_LOCATION_URL $ASSET_LOCATION_URL
ENV SECRET_KEY_BASE $SECRET_KEY_BASE
ENV RACK_ENV $RACK_ENV
ENV RAILS_SERVE_STATIC_FILES true
# Precompile assets
RUN rails assets:precompile
# Add additional labels to our image
ARG GIT_SHA=unknown
ARG GIT_TAG=unknown
LABEL git-sha=$GIT_SHA \
git-tag=$GIT_TAG \
rack-env=$RACK_ENV \
maintainer=mattrayner1@gmail.com
# Launch puma
CMD ["bundle", "exec", "rails", "s", "Puma"]