Skip to content

Commit

Permalink
build: copy in specific folders and use Alpine (#8)
Browse files Browse the repository at this point in the history
* build: copy in exact files required

* build: use Alpine in Docker container
  • Loading branch information
boringcactus authored Nov 13, 2023
1 parent af77da4 commit 10c30c0
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# --- Set up Elixir build ---
FROM hexpm/elixir:1.15.7-erlang-26.1.2-debian-bullseye-20231009-slim as elixir-builder
FROM hexpm/elixir:1.15.7-erlang-26.1.2-alpine-3.18.4 as elixir-builder

ENV LANG=C.UTF-8 MIX_ENV=prod

RUN apt-get update --allow-releaseinfo-change
RUN apt-get install --no-install-recommends --yes \
build-essential ca-certificates git
RUN apk add --no-cache \
git
RUN mix local.hex --force
RUN mix local.rebar --force

WORKDIR /root
ADD . .
COPY ./mix.exs mix.exs
COPY ./mix.lock mix.lock
RUN mix deps.get --only prod
RUN mix deps.compile


# --- Build Elixir release ---
Expand All @@ -20,20 +21,23 @@ FROM elixir-builder as app-builder
ENV LANG=C.UTF-8 MIX_ENV=prod

WORKDIR /root
COPY ./assets assets
COPY ./config config
COPY ./lib lib
COPY ./priv priv
RUN mix compile
RUN mix assets.deploy
RUN mix phx.digest
RUN mix release


# --- Set up runtime container ---
FROM debian:bullseye-slim
FROM alpine:3.18.4

ENV LANG=C.UTF-8 MIX_ENV=prod REPLACE_OS_VARS=true

RUN apt-get update --allow-releaseinfo-change \
&& apt-get install --no-install-recommends --yes dumb-init wget \
&& rm -rf /var/lib/apt/lists/*
RUN apk add --no-cache \
dumb-init libgcc libstdc++ ncurses-libs

# Create non-root user
RUN addgroup --system mobileappbackend && adduser --system --ingroup mobileappbackend mobileappbackend
Expand Down

0 comments on commit 10c30c0

Please sign in to comment.