Skip to content
Permalink
266febe1db
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
78 lines (63 sloc) 2.12 KB
# The version of Alpine to use for the final image
# This should match the version of Alpine that the `elixir:1.7.2-alpine` image uses
ARG ALPINE_VERSION=3.10
FROM elixir:1.9-alpine AS builder
# The following are build arguments used to change variable parts of the image.
# The name of your application/release (required)
ARG APP_NAME
# The version of the application we are building (required)
ARG APP_VSN
# The environment to build with
ARG MIX_ENV=prod
# Set this to true if this release is not a Phoenix app
ARG SKIP_PHOENIX=true
# If you are using an umbrella project, you can change this
# argument to the directory the Phoenix app is in so that the assets
# can be built
ARG PHOENIX_SUBDIR=sf
ENV SKIP_PHOENIX=${SKIP_PHOENIX} \
APP_NAME=${APP_NAME} \
APP_VSN=${APP_VSN} \
MIX_ENV=${MIX_ENV}
# By convention, /opt is typically used for applications
WORKDIR /opt/app
# This copies our app source code into the build container
COPY . .
# This step installs all the build tools we'll need
RUN apk update && \
apk upgrade --no-cache && \
apk add --no-cache \
nodejs \
yarn \
git \
build-base && \
mix local.rebar --force && \
mix local.hex --force
RUN pwd && ls -l && mix do deps.get --only prod, deps.compile, compile
# This step builds assets for the Phoenix app (if there is one)
# If you aren't building a Phoenix app, pass `--build-arg SKIP_PHOENIX=true`
# This is mostly here for demonstration purposes
RUN if [ ! "$SKIP_PHOENIX" = "true" ]; then \
cd ${PHOENIX_SUBDIR}/assets && \
yarn install && \
yarn deploy && \
mix phx.digest; \
fi
RUN \
mkdir -p /opt/built && \
MIX_ENV=prod mix release --path /opt/built && \
pwd && ls -l /opt/built
# From this line onwards, we're in a new image, which will be the image used in production
FROM alpine:${ALPINE_VERSION}
# The name of your application/release (required)
ARG APP_NAME
RUN apk update && \
apk add --no-cache \
bash \
openssl-dev
ENV REPLACE_OS_VARS=true \
APP_NAME=${APP_NAME}
WORKDIR /opt/app
COPY --from=builder /opt/built .
#CMD trap 'exit' INT; /opt/app/_build/prod/rel/sf/bin/sf start
CMD bin/sf start