-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
120 lines (94 loc) · 2.95 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# ruby build stage
FROM ruby:3.2-alpine as ruby-build-env
MAINTAINER mdouchement
# Set the locale
ENV LANG c.UTF-8
# App
ENV GEM_HOME /usr/src/app/vendor/gems
ENV GEM_PATH /usr/src/app/vendor/gems
ENV RAILS_ENV production
ENV RACK_ENV production
# Namespace for the application. Necessary for the asset compilation
# Update as needed
# ENV RAILS_RELATIVE_URL_ROOT /mersea
ENV SECRET_KEY_BASE tmp_376ea25aaa66984733a90920c263ba138e1e571aaf3a1a54cd2b819cb06e8b7fb311027b639eb8f55d8d53c27cf2df378ceb36008462057861d824bd13a0
# Install build dependencies
RUN apk upgrade
RUN apk add --update --no-cache \
git \
bash \
build-base \
postgresql-dev \
icu-dev \
libxml2-dev \
libxslt-dev \
tzdata \
nodejs
# Bundler 2.x.x
RUN gem install bundler
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app
# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config build.nokogiri
RUN bundle config --global frozen 1
RUN bundle install --deployment --without development test
# Admin assets
RUN bundle exec rake assets:precompile
# javascript build stage
FROM node:fermium-alpine as js-build-env
MAINTAINER mdouchement franckke
RUN apk upgrade
RUN apk add --update --no-cache \
git
COPY --from=ruby-build-env /usr/src/app /usr/src/app
ENV NODE_ENV production
ENV VUE_APP_MAPBOX_TOKEN pk.eyJ1IjoiZnJhbmNrayIsImEiOiJjanNianhvM3owY2thNGJycGs4eTRtNmlmIn0.C-IMo3-GDK62hskzUEIJxA
ENV VUE_APP_BUGSNAG_TOKEN b4eb2302530535245e3e25639d385ea8
ENV VUE_APP_FATHOM_HOSTNAME=analytics.oceanplastictracker.com
ENV VUE_APP_FATHOM_SITE_ID=IIYJS
WORKDIR /usr/src/app/frontend
RUN yarn install --production=false --frozen-lockfile && yarn cache clean
RUN yarn run build --mode production
WORKDIR /usr/src/app
RUN mv frontend/dist/* public/
# Remove this huge folder to prepare the next stage.
RUN rm -rf frontend .git
# final stage
FROM ruby:3.2-alpine
MAINTAINER mdouchement
# Set the locale
ENV LANG c.UTF-8
# App
ENV GEM_HOME /usr/src/app/vendor/gems
ENV GEM_PATH /usr/src/app/vendor/gems
ENV RAILS_ENV production
ENV RACK_ENV production
ENV EXECJS_RUNTIME Disabled
# Namespace for the application. Necessary for the asset compilation
# Update as needed
# ENV RAILS_RELATIVE_URL_ROOT /mersea
ENV SECRET_KEY_BASE tmp_376ea25aaa66984733a90920c263ba138e1e571aaf3a1a54cd2b819cb06e8b7fb311027b639eb8f55d8d53c27cf2df378ceb36008462057861d824bd13a0
# Install build dependencies
RUN apk upgrade
RUN apk add --update --no-cache \
postgresql-dev \
libxml2-dev \
libxslt-dev \
icu-libs \
tzdata \
file \
imagemagick
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY --from=js-build-env /usr/src/app /usr/src/app
# Bundler 2.x.x
RUN gem install bundler
# Resync bundler
RUN bundle install --deployment --without development test
COPY dockerfiles/nginx.conf /etc/nginx/conf.d/default.conf
VOLUME ["/etc/nginx/conf.d"]
VOLUME ["/usr/src/app/public"]
EXPOSE 3000
CMD SECRET_KEY_BASE=$(bundle exec rake secret) \
bundle exec puma -p 3000