-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
100 lines (84 loc) · 3.23 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
FROM ruby:3.0.1-slim
ARG BUILD_ENV=development
ARG RUBY_ENV=development
ARG APP_HOME=/seeker
ARG NODE_ENV=development
ARG ASSET_HOST=http://localhost
# Define all the envs here
ENV BUILD_ENV=$BUILD_ENV \
RACK_ENV=$RUBY_ENV \
RAILS_ENV=$RUBY_ENV \
PORT=3000 \
BUNDLE_JOBS=4 \
BUNDLE_PATH="/bundle" \
ASSET_HOST=$ASSET_HOST \
NODE_ENV=$NODE_ENV \
NODE_SOURCE_VERSION=16 \
LANG="en_US.UTF-8" \
LC_ALL="en_US.UTF-8" \
LANGUAGE="en_US:en"
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends apt-transport-https curl gnupg net-tools && \
apt-get install -y --no-install-recommends build-essential libpq-dev && \
apt-get install -y --no-install-recommends rsync locales chrpath pkg-config libfreetype6 libfontconfig1 git cmake wget unzip nginx && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Add Yarn repository
# Add the PPA (personal package archive) maintained by NodeSource
# This will have more up-to-date versions of Node.js than the official Debian repositories
ADD https://dl.yarnpkg.com/debian/pubkey.gpg /tmp/yarn-pubkey.gpg
RUN apt-key add /tmp/yarn-pubkey.gpg && rm /tmp/yarn-pubkey.gpg && \
echo "deb http://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \
curl -sL https://deb.nodesource.com/setup_"$NODE_SOURCE_VERSION".x | bash - && \
apt-get update -qq && \
apt-get install -y --no-install-recommends nodejs yarn && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Set up the Chrome PPA and install Chrome Headless
RUN if [ "$BUILD_ENV" = "test" ]; then \
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo 'deb http://dl.google.com/linux/chrome/deb/ stable main' >> /etc/apt/sources.list.d/google-chrome.list && \
apt-get update -qq && \
apt-get install -y --no-install-recommends google-chrome-stable && \
rm /etc/apt/sources.list.d/google-chrome.list && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* ; \
fi
WORKDIR $APP_HOME
# Nginx config
COPY config/nginx/app.conf.template /etc/nginx/conf.d/default.conf
# Skip installing gem documentation
RUN mkdir -p /usr/local/etc \
&& { \
echo '---'; \
echo ':update_sources: true'; \
echo ':benchmark: false'; \
echo ':backtrace: true'; \
echo ':verbose: true'; \
echo 'gem: --no-ri --no-rdoc'; \
echo 'install: --no-document'; \
echo 'update: --no-document'; \
} >> /usr/local/etc/gemrc
# Copy all denpendencies from app and engines into tmp/docker to install
COPY tmp/docker ./
# Install Ruby gems
RUN gem install bundler && \
bundle config set jobs $BUNDLE_JOBS && \
bundle config set path $BUNDLE_PATH && \
if [ "$BUILD_ENV" = "production" ]; then \
bundle config set deployment yes && \
bundle config set without 'development test' ; \
fi && \
bundle install
# Install JS dependencies
COPY package.json yarn.lock ./
RUN yarn install --network-timeout 100000
# Copying the app files must be placed after the dependencies setup
# since the app files always change thus cannot be cached
COPY . ./
# Remove tmp/docker in the final image
RUN rm -rf tmp/docker
# Compile assets
RUN bin/docker-assets-precompile
EXPOSE $PORT
CMD ./bin/start.sh