2019-01-08 05:25:21 +03:00
|
|
|
#
|
|
|
|
# Step 1 - Build the OTP binary
|
|
|
|
#
|
2019-07-30 14:30:32 +03:00
|
|
|
FROM elixir:1.9-alpine AS builder
|
2019-01-08 05:25:21 +03:00
|
|
|
|
2019-09-07 23:27:26 +03:00
|
|
|
ARG APP_VERSION=latest
|
|
|
|
ENV APP_VERSION=${APP_VERSION}
|
|
|
|
ENV MIX_ENV=prod
|
2019-01-08 05:25:21 +03:00
|
|
|
|
|
|
|
WORKDIR /build
|
|
|
|
|
2019-07-22 20:01:36 +03:00
|
|
|
RUN apk --no-cache update && \
|
|
|
|
apk --no-cache upgrade && \
|
|
|
|
apk --no-cache add make g++ git openssl-dev python yaml-dev
|
2019-01-08 05:25:21 +03:00
|
|
|
|
|
|
|
RUN mix local.rebar --force && \
|
|
|
|
mix local.hex --force
|
|
|
|
|
|
|
|
COPY mix.* ./
|
2019-07-30 14:44:06 +03:00
|
|
|
COPY lib lib
|
|
|
|
COPY priv priv
|
|
|
|
COPY config config
|
|
|
|
COPY mix.exs .
|
|
|
|
COPY mix.lock .
|
2019-09-07 23:27:26 +03:00
|
|
|
|
|
|
|
RUN mix deps.get --only prod
|
|
|
|
RUN mix deps.compile --only prod
|
|
|
|
RUN mix compile --only prod
|
2019-01-08 05:25:21 +03:00
|
|
|
|
|
|
|
RUN mkdir -p /opt/build && \
|
2019-07-30 14:30:32 +03:00
|
|
|
mix release && \
|
2019-09-07 23:27:26 +03:00
|
|
|
cp -R _build/prod/rel/accent/* /opt/build
|
2019-01-08 05:25:21 +03:00
|
|
|
|
2019-07-22 20:01:36 +03:00
|
|
|
#
|
|
|
|
# Step 2 - Build webapp and jipt deps
|
|
|
|
#
|
2019-11-26 04:21:00 +03:00
|
|
|
FROM node:10.16-alpine AS webapp-builder
|
2019-07-22 20:01:36 +03:00
|
|
|
RUN apk --no-cache update && \
|
|
|
|
apk --no-cache upgrade && \
|
2019-11-26 04:21:00 +03:00
|
|
|
apk --no-cache add git
|
2019-07-22 20:01:36 +03:00
|
|
|
WORKDIR /opt/build
|
|
|
|
COPY webapp .
|
|
|
|
RUN npm ci --no-audit --no-color && \
|
|
|
|
npm run build-production
|
2019-01-08 05:25:21 +03:00
|
|
|
|
2019-11-26 04:21:00 +03:00
|
|
|
FROM node:10.16-alpine AS jipt-builder
|
2019-07-22 20:01:36 +03:00
|
|
|
RUN apk --no-cache update && \
|
|
|
|
apk --no-cache upgrade && \
|
2019-11-26 04:21:00 +03:00
|
|
|
apk --no-cache add git
|
2019-07-22 20:01:36 +03:00
|
|
|
WORKDIR /opt/build
|
|
|
|
COPY jipt .
|
|
|
|
RUN npm ci --no-audit --no-color && \
|
|
|
|
npm run build-production
|
2019-01-08 05:25:21 +03:00
|
|
|
#
|
2019-07-22 20:01:36 +03:00
|
|
|
# Step 3 - Build a lean runtime container
|
2019-01-08 05:25:21 +03:00
|
|
|
#
|
2019-03-11 19:51:16 +03:00
|
|
|
FROM alpine:3.9
|
2019-01-08 05:25:21 +03:00
|
|
|
|
2019-09-07 23:27:26 +03:00
|
|
|
ARG APP_VERSION=latest
|
|
|
|
ENV APP_VERSION=${APP_VERSION}
|
2019-01-08 05:25:21 +03:00
|
|
|
|
|
|
|
RUN apk --no-cache update && \
|
|
|
|
apk --no-cache upgrade && \
|
2019-07-19 00:13:24 +03:00
|
|
|
apk --no-cache add bash openssl erlang-crypto yaml-dev
|
2019-01-08 05:25:21 +03:00
|
|
|
|
2019-09-07 23:27:26 +03:00
|
|
|
WORKDIR /opt/accent
|
2019-01-08 05:25:21 +03:00
|
|
|
|
2019-07-22 20:01:36 +03:00
|
|
|
# Copy the OTP binary and assets deps from the build step
|
2019-01-08 05:25:21 +03:00
|
|
|
COPY --from=builder /opt/build .
|
2019-12-04 20:35:52 +03:00
|
|
|
COPY --from=webapp-builder /opt/build/webapp-dist ./webapp-dist
|
|
|
|
COPY --from=jipt-builder /opt/build/jipt-dist ./jipt-dist
|
2019-01-08 05:25:21 +03:00
|
|
|
|
2019-09-07 23:27:26 +03:00
|
|
|
RUN mv /opt/accent/webapp-dist /opt/accent/lib/accent-$APP_VERSION/priv/static/webapp && \
|
|
|
|
mv /opt/accent/jipt-dist /opt/accent/lib/accent-$APP_VERSION/priv/static/jipt
|
2019-07-19 00:13:24 +03:00
|
|
|
|
2019-01-08 05:25:21 +03:00
|
|
|
# Copy the entrypoint script
|
|
|
|
COPY priv/scripts/docker-entrypoint.sh /usr/local/bin
|
|
|
|
RUN chmod a+x /usr/local/bin/docker-entrypoint.sh
|
|
|
|
|
|
|
|
# Create a non-root user
|
2019-09-07 23:27:26 +03:00
|
|
|
RUN adduser -D accent && chown -R accent: /opt/accent
|
2019-01-08 05:25:21 +03:00
|
|
|
|
2019-09-07 23:27:26 +03:00
|
|
|
USER accent
|
2019-01-08 05:25:21 +03:00
|
|
|
|
|
|
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
2019-07-30 14:30:32 +03:00
|
|
|
CMD ["start"]
|