Dockerfile for building
This commit is contained in:
parent
de1b1bd484
commit
590be07076
72
Dockerfile
Normal file
72
Dockerfile
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
# syntax=docker/dockerfile:1.7
|
||||||
|
|
||||||
|
# Use the official Alpine Elixir image; keep the version in sync with mix.exs
|
||||||
|
ARG ELIXIR_VERSION=1.15
|
||||||
|
FROM elixir:${ELIXIR_VERSION}-alpine AS build
|
||||||
|
|
||||||
|
ENV LANG="en_US.UTF-8" \
|
||||||
|
MIX_ENV="prod" \
|
||||||
|
HOME="/app"
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apk update && \
|
||||||
|
apk add --no-cache \
|
||||||
|
build-base \
|
||||||
|
sqlite-dev \
|
||||||
|
openssl-dev \
|
||||||
|
ca-certificates
|
||||||
|
|
||||||
|
RUN mix do local.hex --force, local.rebar --force
|
||||||
|
|
||||||
|
# Only copy files necessary to download deps to maximize layer caching
|
||||||
|
COPY mix.exs mix.lock ./
|
||||||
|
COPY config config
|
||||||
|
|
||||||
|
RUN mix deps.get --only ${MIX_ENV} && \
|
||||||
|
mix deps.compile
|
||||||
|
|
||||||
|
# Copy the rest of the application source
|
||||||
|
COPY lib lib
|
||||||
|
COPY priv priv
|
||||||
|
COPY assets assets
|
||||||
|
|
||||||
|
RUN mix compile
|
||||||
|
RUN mix assets.deploy
|
||||||
|
RUN mix release
|
||||||
|
|
||||||
|
# Minimal runtime image
|
||||||
|
FROM alpine:3.19 AS app
|
||||||
|
|
||||||
|
ENV LANG="en_US.UTF-8" \
|
||||||
|
MIX_ENV="prod" \
|
||||||
|
PORT="4000" \
|
||||||
|
PHX_SERVER="true" \
|
||||||
|
DATABASE_PATH="/app/data/action_requests_demo.db"
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
openssl \
|
||||||
|
ncurses-libs \
|
||||||
|
libstdc++ \
|
||||||
|
sqlite \
|
||||||
|
ca-certificates
|
||||||
|
|
||||||
|
# Keep SQLite data outside of the release directory so it can persist as a volume
|
||||||
|
RUN install -d -m 0755 /app/data
|
||||||
|
|
||||||
|
COPY --from=build /app/_build/prod/rel/action_requests_demo ./
|
||||||
|
|
||||||
|
RUN addgroup -S app && \
|
||||||
|
adduser -S app -G app && \
|
||||||
|
chown -R app:app /app
|
||||||
|
|
||||||
|
USER app
|
||||||
|
|
||||||
|
EXPOSE 4000
|
||||||
|
VOLUME ["/app/data"]
|
||||||
|
|
||||||
|
ENTRYPOINT ["./bin/action_requests_demo"]
|
||||||
|
CMD ["start"]
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user