chore(build): create dockerfile for release deployment
Signed-off-by: SphericalKat <amolele@gmail.com>
This commit is contained in:
5 files changed
+90
-4
No files matched your search
+50
@@ -0,0 +1,50 @@
|
||||
FROM elixir:alpine AS build
|
||||
|
||||
# install build dependencies
|
||||
RUN apk add --no-cache build-base npm git curl py-pip
|
||||
|
||||
# prepare build dir
|
||||
WORKDIR /app
|
||||
|
||||
# install hex + rebar
|
||||
RUN mix local.hex --force && \
|
||||
mix local.rebar --force
|
||||
|
||||
# set build ENV
|
||||
ENV MIX_ENV=prod
|
||||
|
||||
# install mix dependencies
|
||||
COPY mix.exs mix.lock ./
|
||||
COPY config config
|
||||
RUN mix do deps.get, deps.compile
|
||||
|
||||
# build assets
|
||||
COPY assets/package.json assets/package-lock.json ./assets/
|
||||
RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error
|
||||
|
||||
COPY priv priv
|
||||
COPY assets assets
|
||||
RUN npm run --prefix ./assets deploy
|
||||
RUN mix phx.digest
|
||||
|
||||
# compile and build release
|
||||
COPY lib lib
|
||||
# uncomment COPY if rel/ exists
|
||||
# COPY rel rel
|
||||
RUN mix do compile, release
|
||||
|
||||
# prepare release image
|
||||
FROM alpine:3.9 AS app
|
||||
RUN apk add --no-cache openssl ncurses-libs libstdc++
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN chown nobody:nobody /app
|
||||
|
||||
USER nobody:nobody
|
||||
|
||||
COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/ketbin ./
|
||||
|
||||
ENV HOME=/app
|
||||
|
||||
CMD ["bin/ketbin", "start"]
|
||||
Reference in new issue
Block a user