# https://elixirforum.com/t/could-use-some-feedback-on-this-multistage-dockerfile-1st-elixir-phoenix-deployment/30862/10?
########################
### Dependency stage ###
########################
FROM hexpm/elixir:1.11.2-erlang-23.1.3-debian-buster-20201012 AS deps
# install build dependencies
RUN apt-get -qq update && \
apt-get -qq -y install build-essential npm git python --fix-missing --no-install-recommends
# prepare build dir
WORKDIR /app
ARG MIX_ENV
ARG RELEASE_LEVEL
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
# Update timezone
ENV TZ=Asia/Singapore
# install hex + rebar
RUN mix local.hex --force && \
mix local.rebar --force
# set build ENV
ENV MIX_ENV=${MIX_ENV}
ENV RELEASE_LEVEL=${RELEASE_LEVEL}
COPY mix.exs mix.lock ./
COPY config config
# install mix dependencies
RUN mix deps.get --only ${MIX_ENV}
RUN mix deps.compile
########################
# Build Phoenix assets #
########################
# Using stretch for now because it includes Python
# Otherwise you get errors, could use a smaller image though
FROM node:14.15.1-stretch AS assets
WORKDIR /app/assets
COPY --from=deps /app/deps /app/deps/
COPY assets/package.json assets/package-lock.json ./
RUN npm ci --progress=false --no-audit --loglevel=error
COPY priv ./
COPY assets/ ./
RUN npm run deploy
#########################
# Create Phoenix digest #
#########################
FROM deps AS digest
COPY --from=assets /app/priv ./priv
RUN mix phx.digest
#######################
#### Create release ###
#######################
FROM digest AS release
ARG MIX_ENV
ENV MIX_ENV=${MIX_ENV}
COPY lib ./lib
RUN mix do compile, release
#################################################
# Create the actual image that will be deployed #
#################################################
FROM debian:buster-slim AS deploy
# Install stable dependencies that don't change often
RUN apt-get update && \
apt-get install -y --no-install-recommends \
apt-utils \
openssl \
curl \
wget && \
rm -rf /var/lib/apt/lists/*
# Set WORKDIR after setting user to nobody so it automatically gets the right permissions
# When the app starts it will need to be able to create a tmp directory in /app
WORKDIR /app
ARG MIX_ENV
ARG RELEASE_LEVEL
ENV MIX_ENV=${MIX_ENV}
ENV RELEASE_LEVEL=${RELEASE_LEVEL}
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
# Update timezone
ENV TZ=Asia/Singapore
COPY --from=release /app/_build/${MIX_ENV}/rel/ghost_rider ./
ENV HOME=/app
# Exposes port to the host machine
EXPOSE 8080
CMD ["bin/ghost_rider", "start"]
got the build to work following
Could use some feedback on this multistage dockerfile (1st elixir/phoenix deployment)?
but seems that doesn’t take priv into account and have missing files for tailwind. any examples docker file that uses tailwind with phoenix ?