-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
86 lines (61 loc) · 1.64 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
# syntax=docker/dockerfile:1
ARG NODE_VERSION
ARG RUBY_VERSION
### Frontend ###
FROM node:${NODE_VERSION}-alpine AS frontend
ARG NPM_VERSION
RUN --mount=type=cache,id=loot-npm,target=/root/.npm \
npm install --global npm@$NPM_VERSION
WORKDIR /build
COPY --link package*.json ./
RUN --mount=type=cache,id=loot-npm,target=/root/.npm \
npm ci
COPY --link \
tsconfig.json \
webpack.common.js \
webpack.prod.js ./
COPY --link src src/
RUN npm run build
### Backend ###
FROM ruby:${RUBY_VERSION}-alpine AS backend
RUN apk add --no-cache \
build-base \
postgresql-dev
WORKDIR /build
ENV RACK_ENV=production
COPY --link \
.tool-versions \
Gemfile* ./
RUN --mount=type=cache,id=loot-bundler,target=tmp/vendor/bundle \
bundle config set --local without development:test; \
bundle config set --local deployment true; \
bundle config set --local clean true;\
bundle config set --local path tmp/vendor/bundle; \
bundle install --jobs=4; \
cp -a tmp/vendor ./;
### App ###
FROM ruby:${RUBY_VERSION}-alpine AS app
RUN apk add --no-cache \
libpq \
tzdata
RUN adduser --system --uid 100 loot
USER loot
WORKDIR /loot
ENV RACK_ENV=production
ENV RAILS_ENV=production
ENV TZ=Australia/Sydney
RUN \
bundle config set --local without development:test; \
bundle config set --local deployment true;
COPY --link --chown=100 \
.tool-versions \
config.ru \
Gemfile* \
Rakefile ./
COPY --link --chown=100 db db/
COPY --link --chown=100 config config/
COPY --link --chown=100 app app/
COPY --link --chown=100 --from=backend build/vendor/bundle vendor/bundle/
COPY --link --chown=100 --from=frontend build/public public/
EXPOSE 3000
CMD ["bundle", "exec", "puma"]