Last active
October 6, 2021 20:49
-
-
Save evokelektrique/2ca456f79d67259f1750b22a803dcd7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM hexpm/elixir:1.12.0-erlang-24.0-alpine-3.13.3 AS build | |
# install build dependencies | |
RUN apk add --no-cache build-base npm git python3 | |
# 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.13 AS app | |
RUN apk add --no-cache bash openssl postgresql-client ncurses-libs libstdc++ | |
ENV MIX_ENV=prod | |
WORKDIR /app | |
COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/myphoenixapp ./ | |
COPY entrypoint.sh . | |
RUN chown nobody:nobody /app | |
USER nobody:nobody | |
ENV HOME=/app | |
CMD ["bash", "/app/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# docker entrypoint script. | |
# assign a default for the database_user | |
DB_USER=${DATABASE_USER:-postgres} | |
# wait until Postgres is ready | |
while ! pg_isready -q -h $DATABASE_HOST -p 5432 -U $DB_USER | |
do | |
echo "$(date) - waiting for database to start" | |
sleep 2 | |
done | |
bin="/app/bin/myphoenixapp" | |
eval "$bin eval \"MyPhoenixApp.Release.migrate\"" | |
# start the elixir application | |
exec "$bin" "start" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment