-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (51 loc) · 1.82 KB
/
Dockerfile
File metadata and controls
75 lines (51 loc) · 1.82 KB
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
ARG RUBY_VERSION=3.3.10
#use ruby base image
FROM ruby:$RUBY_VERSION-slim AS base
# set work dir
WORKDIR /code
# install dependencies
RUN apt-get update \
&& apt-get install build-essential curl file git gnupg2 imagemagick libpq-dev libyaml-dev nodejs npm -y \
&& apt-get clean
# install yarn to manage JS dependencies
RUN npm install --global yarn@1.22.22
# install supercronic - a cron alternative
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-amd64 \
SUPERCRONIC=supercronic-linux-amd64 \
SUPERCRONIC_SHA1SUM=048b95b48b708983effb2e5c935a1ef8483d9e3e
RUN curl -fsSLO "$SUPERCRONIC_URL" \
&& echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \
&& chmod +x "$SUPERCRONIC" \
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
ENTRYPOINT ["docker/entrypoint.sh"]
EXPOSE 3000
FROM base AS development
CMD bundle exec rails server -b 0.0.0.0
FROM base AS production
# copy gemfile
COPY Gemfile Gemfile.lock ./
# install gems
RUN bundle check || bundle install
# copy package file
COPY package.json yarn.lock ./
# install js dependencies
RUN yarn install --frozen-lockfile --non-interactive
# copy code
COPY . .
# precompile assets
RUN bundle exec rake assets:precompile
ARG CR
# chown to root group to allow rwx when pulling from container registry
# and do not bake secrets
RUN if [ "$CR" = "True" ]; then \
mkdir -p /code && chown -R 0:0 /code \
&& chmod -R g+rwX /code \
&& rm -rf /code/config/tess.yml \
/code/config/secrets.yml \
.env; \
fi
# run rails server, need bind for docker
CMD bundle exec whenever > /code/tess.crontab \
&& (supercronic /code/tess.crontab &) \
&& bundle exec rails server -b 0.0.0.0