Created
October 31, 2021 19:14
-
-
Save mazz/3906276dbdb8e42aa7c25bd09223ae2e to your computer and use it in GitHub Desktop.
Dockerfile OK
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
# STEP 1 - BUILD RELEASE | |
# cannot use alpine 3.14.0 because of issue here with bcrypt-elxir compiling using make on docker: | |
# https://github.com/riverrun/bcrypt_elixir/issues/26#issuecomment-881966412 | |
FROM hexpm/elixir:1.12.3-erlang-24.0.6-alpine-3.13.5 AS build | |
# install build dependencies | |
RUN apk add --update git \ | |
build-base \ | |
nodejs-current \ | |
nodejs-npm \ | |
yarn | |
RUN mkdir /app | |
WORKDIR /app | |
# install Hex + Rebar | |
RUN mix do local.hex --force, local.rebar --force | |
# set build ENV | |
ENV MIX_ENV=prod | |
ENV HOSTNAME=faithfulaudio.org | |
ENV DATABASE_URL=ecto://***:***@postgres/faithful_word | |
ENV SECRET_KEY_BASE=*** | |
# install mix dependencies | |
COPY mix.exs mix.lock ./ | |
COPY config config | |
RUN mix deps.get --only $MIX_ENV | |
RUN mix deps.compile | |
# build assets | |
COPY assets assets | |
RUN mix assets.deploy | |
# build project | |
COPY priv priv | |
COPY lib lib | |
RUN mix compile | |
# build release | |
# at this point we should copy the rel directory but | |
# we are not using it so we can omit it | |
# COPY rel rel | |
RUN mix release | |
#################################################################################################### | |
# STEP 2 - FINAL | |
FROM alpine:3.13.5 as app | |
# install runtime dependencies | |
# https://stackoverflow.com/questions/68010688/docker-run-error-loading-shared-library-libstdc-so-6-and-libgcc-s-so-1 | |
RUN apk upgrade --no-cache && \ | |
apk add --update bash \ | |
openssl \ | |
postgresql-client \ | |
libstdc++ | |
EXPOSE 4000 | |
ENV MIX_ENV=prod | |
ENV DATABASE_URL=ecto://***:***@postgres/faithful_word | |
ENV SECRET_KEY_BASE=*** | |
# prepare app directory | |
RUN mkdir /app | |
WORKDIR /app | |
# copy release to app container | |
COPY --from=build /app/_build/prod/rel/faithful_word . | |
COPY entrypoint.sh . | |
RUN chown -R nobody: /app | |
USER nobody | |
ENV HOME=/app | |
CMD ["bash", "/app/entrypoint.sh"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment