# [[ META-BUILDER ]]

FROM alpine:3 AS kethel
RUN apk add --no-cache elixir git tzdata nodejs npm
RUN ln -s /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime

# fetch deps
WORKDIR /usr/local/app
WORKDIR "/usr/local/app/kethel"
COPY kethel ./
RUN npm i

# build www.m1kadev.nl
WORKDIR /usr/local/app

COPY rss ./rss
COPY static ./static
COPY favicon.ico .

COPY templates ./templates
COPY bricks ./bricks
COPY styles ./styles

COPY scripts ./scripts
COPY pages ./pages
COPY thoughts ./thoughts

COPY .git /.git

WORKDIR "/usr/local/app/kethel"
RUN mix deps.get
RUN mix compile.rambo

RUN mix run main.exs -- ..

# [[ SERVER ]]
FROM nginx:mainline AS server

COPY --from=kethel /usr/local/app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
