fix/docker-build-permissions (#207)
Reviewed-on: graham/towerops-web#207
This commit is contained in:
parent
2a84df471d
commit
bd3f872776
1 changed files with 7 additions and 20 deletions
|
|
@ -1,5 +1,3 @@
|
|||
# syntax=docker/dockerfile:1.4
|
||||
|
||||
# Find eligible builder and runner images on Docker Hub. We use Ubuntu/Debian
|
||||
# instead of Alpine to avoid DNS resolution issues in production.
|
||||
#
|
||||
|
|
@ -38,30 +36,22 @@ WORKDIR /app
|
|||
ENV MIX_ENV="prod"
|
||||
|
||||
# install hex + rebar
|
||||
RUN --mount=type=cache,target=/root/.hex \
|
||||
--mount=type=cache,target=/root/.mix \
|
||||
mix local.hex --force \
|
||||
RUN mix local.hex --force \
|
||||
&& mix local.rebar --force
|
||||
|
||||
# install mix dependencies
|
||||
COPY mix.exs mix.lock ./
|
||||
COPY vendor vendor
|
||||
RUN --mount=type=cache,target=/root/.hex \
|
||||
--mount=type=cache,target=/root/.mix \
|
||||
mix deps.get --only $MIX_ENV
|
||||
RUN mix deps.get --only $MIX_ENV
|
||||
RUN mkdir config
|
||||
|
||||
# copy compile-time config files before we compile dependencies
|
||||
# to ensure any relevant config change will trigger the dependencies
|
||||
# to be re-compiled.
|
||||
COPY config/config.exs config/${MIX_ENV}.exs config/
|
||||
RUN --mount=type=cache,target=/root/.hex \
|
||||
--mount=type=cache,target=/root/.mix \
|
||||
mix deps.compile
|
||||
RUN mix deps.compile
|
||||
|
||||
RUN --mount=type=cache,target=/root/.mix \
|
||||
--mount=type=cache,target=/root/.npm \
|
||||
mix assets.setup
|
||||
RUN mix assets.setup
|
||||
|
||||
COPY priv priv
|
||||
|
||||
|
|
@ -73,21 +63,18 @@ RUN cd c_src && make
|
|||
COPY lib lib
|
||||
|
||||
# Compile the release
|
||||
RUN --mount=type=cache,target=/root/.mix \
|
||||
mix compile
|
||||
RUN mix compile
|
||||
|
||||
COPY assets assets
|
||||
|
||||
# compile assets
|
||||
RUN --mount=type=cache,target=/root/.mix \
|
||||
mix assets.deploy
|
||||
RUN mix assets.deploy
|
||||
|
||||
# Changes to config/runtime.exs don't require recompiling the code
|
||||
COPY config/runtime.exs config/
|
||||
|
||||
COPY rel rel
|
||||
RUN --mount=type=cache,target=/root/.mix \
|
||||
mix release
|
||||
RUN mix release
|
||||
|
||||
# start a new build stage so that the final image will only contain
|
||||
# the compiled release and other runtime necessities
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue