-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
81 lines (61 loc) · 2.14 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
FROM ruby:2.6.3-alpine AS build-env
ARG RAILS_ROOT=/backend
ARG BUILD_PACKAGES="build-base curl-dev git snappy sqlite sqlite-dev"
ARG DEV_PACKAGES="yaml-dev zlib-dev nodejs yarn build-base libexecinfo automake autoconf libtool"
ARG RUBY_PACKAGES="tzdata"
ENV BUNDLE_APP_CONFIG="$RAILS_ROOT/.bundle"
WORKDIR $RAILS_ROOT
# install packages
RUN apk update \
&& apk upgrade \
&& apk add --update --no-cache $BUILD_PACKAGES $DEV_PACKAGES \
$RUBY_PACKAGES
RUN gem install bundler -v 2.1.4
COPY backend/Gemfile* backend/package.json ./
RUN bundle install --path=vendor/bundle \
# Remove unneeded files (cached *.gem, *.o, *.c)
&& rm -rf vendor/bundle/ruby/2.6.0/cache/*.gem \
&& find vendor/bundle/ruby/2.6.0/gems/ -name "*.c" -delete \
&& find vendor/bundle/ruby/2.6.0/gems/ -name "*.o" -delete
# RUN yarn install
COPY backend/ .
RUN bin/rails assets:precompile
# Remove folders not needed in resulting image
RUN rm -rf node_modules tmp/cache app/assets vendor/assets spec
# Building angular
FROM node:12.6-alpine AS angular-build
RUN apk add --no-cache \
build-base \
python
ARG ANGULAR_ROOT=/frontend
WORKDIR $ANGULAR_ROOT
COPY frontend/package.json .
COPY frontend/package-lock.json .
RUN npm clean-install
COPY frontend/ .
RUN npm run build
# Main image
FROM ruby:2.6.3-alpine
LABEL maintainer="[email protected]"
LABEL name="blazeey"
ARG RAILS_ROOT=/backend
ARG ANGULAR_ROOT=/frontend
ARG PACKAGES="tzdata nodejs bash sqlite sqlite-dev nginx supervisor"
ENV BUNDLE_APP_CONFIG="$RAILS_ROOT/.bundle"
WORKDIR $RAILS_ROOT
# install packages
RUN apk update \
&& apk upgrade \
&& apk add --update --no-cache $PACKAGES \
&& rm -rf /var/cache/apk/*
RUN gem install bundler -v 2.1.4
COPY --from=build-env $RAILS_ROOT $RAILS_ROOT
EXPOSE 3000
RUN mkdir -p /tmp/nginx/client-body
COPY nginx/nginx.conf /etc/nginx/nginx.conf
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=angular-build $ANGULAR_ROOT/dist/kafka-man /usr/share/nginx/html
RUN bundle exec rake db:drop db:create db:migrate
# supervisor base configuration
COPY supervisord.conf /etc/supervisord.conf
CMD ["supervisord", "-c", "/etc/supervisord.conf"]