-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.web
82 lines (60 loc) · 2.5 KB
/
Dockerfile.web
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
############################
# STEP 1 build base image
############################
FROM ruby:2.7.0-buster as base
RUN apt-get update \
&& apt-get install -y apt-transport-https \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
bash curl nginx sudo libjemalloc-dev \
postgresql-client apt-transport-https
ENV RAILS_ENV "production"
ENV RACK_ENV "production"
ENV RAILS_SERVE_STATIC_FILES "enabled"
ENV RAILS_LOG_TO_STDOUT "enabled"
ENV WORKDIR /app/cheidelacoriera
WORKDIR "${WORKDIR}"
COPY .ruby-version Gemfile Gemfile.lock "${WORKDIR}/"
RUN gem install bundler -v "$(tail -n 1 Gemfile.lock | tr -d '[:blank:]')"
RUN bundle install --no-cache --jobs 4 --deployment --without development test lint || bundle check
COPY Rakefile config.ru "${WORKDIR}/"
COPY ./app "${WORKDIR}/app"
COPY ./bin "${WORKDIR}/bin"
COPY ./config "${WORKDIR}/config"
COPY ./data "${WORKDIR}/data"
COPY ./db "${WORKDIR}/db"
COPY ./lib "${WORKDIR}/lib"
COPY ./public "${WORKDIR}/public"
COPY ./vendor "${WORKDIR}/vendor"
############################
# STEP 2 compile assets
############################
FROM base as assets
ENV NODE_ENV "production"
# Install node and yarn
RUN curl --silent --show-error --location \
https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
&& echo "deb https://deb.nodesource.com/node_16.x/ stretch main" > /etc/apt/sources.list.d/nodesource.list \
&& curl --silent --show-error --location https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
# Need to update debian version
&& apt-get update --allow-releaseinfo-change\
&& apt-get install -y --no-install-recommends \
nodejs yarn
COPY .yarnclean yarn.lock package.json .browserslistrc babel.config.js postcss.config.js tsconfig.json "${WORKDIR}/"
RUN rm -rf ./public/assets ./public/packs ./public/packs-test
RUN ./bin/compile_assets
############################
# STEP 3 build web image
############################
FROM base
# Cleanup apt repositories
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Copy the assets from the previous step
COPY --from=assets "${WORKDIR}/public" "${WORKDIR}/public"
COPY ./stack "${WORKDIR}/stack"
COPY ./stack/nginx/default-site.conf /etc/nginx/sites-available/default
COPY ./stack/nginx/nginx.conf /etc/nginx/nginx.conf
ENV SECRET_KEY_BASE $(bundle exec rake secret)
ENTRYPOINT ["./stack/docker/entrypoint.sh"]
CMD ["./stack/docker/start.sh"]